go/scanner: improve error message when a Go file is encoded as UCS-2 #71950
Labels
LibraryProposal
Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool
When a Windows user mistakenly creates a Go text file encoded as UCS-2 (i.e. UTF-16 2-byte encoding) the error message they see is "unexpected NUL", from the zero byte in the encoding of the first rune of the file (typically one of
[ \n/p]
). The scanner could issue a more helpful error: "encoding of file foo.go is UCS-2; Go requires UTF-8".(The presence of a U+FEFF BOM is not by itself indicative of a UCS-2 encoding.)
See also golang/vscode-go#3690
The text was updated successfully, but these errors were encountered: