Unicode support in windows build environment

251 views
Skip to first unread message

Nishant

unread,
Sep 16, 2010, 1:03:25 AM9/16/10
to golang-nuts
I am getting error while using Unicode go source file. After I change
the encoding of ANSI it is working fine.
I have checked with Express Go and it have no issue with Unicode.
There error I am getting with Unicode is

invalid identifier character 0xfeff

Nishant

andrey mirtchovski

unread,
Sep 16, 2010, 1:10:55 AM9/16/10
to golang-nuts
http://msdn.microsoft.com/en-us/library/dd374101(VS.85).aspx

"Since the sequence U+FEFF is exceedingly rare at the beginning of a
regular non-Unicode text file, it can serve as an implicit marker or
signature to identify the file as a Unicode file. Applications that
read both Unicode and non-Unicode text files should use the presence
of this sequence as an indicator that the file is most likely a
Unicode file. Compare this technique to using the MS-DOS EOF marker to
terminate text files."

you may want to try a different editor?

just for test, i tried writing the 0xfeff char to the beginning of an
otherwise valid go program and got the following error:

t.go:1: invalid identifier character 0xfeff
t.go:1: package statement must be first

is that what you're seeing?

Rob 'Commander' Pike

unread,
Sep 16, 2010, 1:29:00 AM9/16/10
to andrey mirtchovski, golang-nuts
U+FEFF is a byte-order mark. It's not meaningful in UTF-8-encoded
files. Your editor is misbehaving.

-rob

Nishant

unread,
Sep 16, 2010, 1:26:38 AM9/16/10
to golang-nuts
I have tried Notepad++ and windows notepad.

UTF 8 =>

$ 8g hello.go
hello.go:1: invalid identifier character 0xfeff
hello.go:1: package statement must be first
hello.go:1: non-declaration statement outside function body
hello.go:1: syntax error: unexpected name, expecting semicolon or
newline

Unicode (in notepad)=>

$ 8g hello.go
hello.go:1: illegal NUL byte
hello.go:1: illegal UTF-8 sequence
ff fe 70 00
hello.go:1: invalid identifier character 0xfffd
hello.go:1: illegal NUL byte
hello.go:1: package statement must be first
hello.go:1: illegal NUL byte
hello.go:1: non-declaration statement outside function body
hello.go:1: syntax error: unexpected name, expecting semicolon or
newline
hello.go:1: illegal NUL byte
hello.go:1: too many errors

Nishant

unread,
Sep 16, 2010, 1:55:14 AM9/16/10
to golang-nuts
Yes my editor was misbehaving. Finally I got UTF-8 encoding working by
using Programmer's Notepad, it is also working with EditPlus.

Thanks
Nishant

fango

unread,
Sep 16, 2010, 1:56:04 AM9/16/10
to golang-nuts

> I am getting error while using Unicode go source file. After I change
> the encoding of ANSI it is working fine.

Don't save as "Unicode", Go source is supposed to be 'UTF-8', though
ANSI is almost a subset.

Cheers,
Fango

Nishant

unread,
Sep 16, 2010, 2:03:29 AM9/16/10
to golang-nuts
I got is working with Notepad ++, supported encoding is "UTF-8 without
BOM"

Thanks
Nishant
Reply all
Reply to author
Forward
0 new messages