-
Notifications
You must be signed in to change notification settings - Fork 18k
text/template: Handling of nbsp (U+00A0) character #71722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
it's only allowed within text, not within actions. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
@seankhliao Thanks for the reply. Could you please point me to the relevant section of documentation that states so? If there isn't one then it's either a bug in code or bug in documentation and this issue should not be closed. I've also noticed another tiny inconsistency within the documentation: https://pkg.go.dev/text/template
whereas the https://pkg.go.dev/unicode#IsSpace
|
As you've seen, template actions use the same space characters as the the Go language: https://go.dev/ref/spec#Tokens. The unicode package uses the Unicode definitions. The Go language spec is clear as to what characters it supports. It's OK that the Go language and Unicode do not have identical definitions for space characters. |
@ianlancetaylor Thanks for your comment!
I would agree with that if not for the statement a few paragraphs above: https://go.dev/ref/spec#Source_code_representation
It's not logical to me to be at the same compliant with UTF-8 (a standard which defines what characters and characters classes there are) and disagree on what a white space character class is. |
Using the UTF-8 encoding does not require anything about the meaning of characters. We also don't use https://www.unicode.org/reports/tr31/ for identifiers. If you like, you can open a language change proposal for the language to start accepting all Unicode whitespace characters. See https://go.dev/s/proposal. If you want to pursue this, please look into what other comparable languages like C++, Rust, Python do. |
Go version
go version go1.24.0 darwin/amd64
Output of
go env
in your module/workspace:What did you do?
I tried to compile the following example:
What did you see happen?
What did you expect to see?
I expected the text to be parsed, i.e.
I had a look at https://pkg.go.dev/text/template and it reads
I'm quite inexperienced with Go so please forgive my possible ignorance; to me this means an nbsp (non-breaking space) character should be handled by
text/template
just fine?The text was updated successfully, but these errors were encountered: