-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
-
What version of Go are you using (
go version)?
1.7 -
What operating system and processor architecture are you using (
go env)?
Windows, arm64
go env:set GOARCH=amd64 set GOBIN= set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\dev\golang set GORACE= set GOROOT=C:\Go set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set CC=gcc set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\Tobias\AppData\Local\Temp\go-build473402786=/tmp/go-build -gno-record-gcc-switches set CXX=g++ set CGO_ENABLED=1 -
What did you do?
I wrote a program which just reads bytes fromos.Stdinand prints their values as Hex to Stdout. I started the program, typed aäto the console and pressed enter. -
What did you expect to see?
I expected to see the correct UTF-8 sequence for aäwhich isC3 A4 -
What did you see instead?
I see the Hex-sequenceE2 80 9E
I found that internal/syscall/windows GetACP() returns 1252 even though I can verify that the ä is encoded in CP850. Because of this wrongly returned codepage, Stdin.readConsole tries to decode the character from 1252 to UTF-8 instead of from 850 to UTF-8. As you see in my Post on Stackoverflow, when I read from stdin through CGO I get the byte 0x84 which is the value for a ä in CP850, it should've been 0xE4 if it were in 1252. The value 0x84 decoded from golang.org/x/text/encoding/charmap.CodePage850 decodes to the correct UTF-8 character.
chcp tells me that the active codepage is 850.