aboutsummaryrefslogtreecommitdiff
path: root/src/internal/syscall
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2016-08-24 10:34:16 +0900
committerAlex Brainman <alex.brainman@gmail.com>2016-09-21 00:38:51 +0000
commitb851ded09a300033849b60ab47a468087ce557a1 (patch)
treeea87f30436784a40099a73e640e56b8f62caa4a6 /src/internal/syscall
parent16f81b617eadc739b9097ce4b7d67e9a00a91c7c (diff)
downloadgo-b851ded09a300033849b60ab47a468087ce557a1.tar.xz
os: use GetConsoleCP() instead of GetACP()
It is possible (and common) for Windows systems to use a different codepage for console applications from that used on normal windowed application (called ANSI codepage); for instance, most of the western Europe uses CP850 for console (for backward compatibility with MS-DOS), while windowed applications use a different codepage depending on the country (eg: CP1252 aka Latin-1). The usage being changed with this commit is specifically related to decoding input coming from the console, so the previous usage of the ANSI codepage was wrong. Also fixes an issue that previous did convert bytes as NFD. Go is designed to handle single Unicode code point. This fix change behaivor to NFC. Fixes #16857. Change-Id: I4f41ae83ece47321b6e9a79a2087ecbb8ac066dd Reviewed-on: https://go-review.googlesource.com/27575 Reviewed-by: Hiroshi Ioka <hirochachacha@gmail.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/internal/syscall')
-rw-r--r--src/internal/syscall/windows/syscall_windows.go1
-rw-r--r--src/internal/syscall/windows/zsyscall_windows.go7
2 files changed, 8 insertions, 0 deletions
diff --git a/src/internal/syscall/windows/syscall_windows.go b/src/internal/syscall/windows/syscall_windows.go
index 47ca602ae1..015862d713 100644
--- a/src/internal/syscall/windows/syscall_windows.go
+++ b/src/internal/syscall/windows/syscall_windows.go
@@ -138,4 +138,5 @@ func Rename(oldpath, newpath string) error {
}
//sys GetACP() (acp uint32) = kernel32.GetACP
+//sys GetConsoleCP() (ccp uint32) = kernel32.GetConsoleCP
//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar
diff --git a/src/internal/syscall/windows/zsyscall_windows.go b/src/internal/syscall/windows/zsyscall_windows.go
index 21fe12fe1b..0b814e9b4a 100644
--- a/src/internal/syscall/windows/zsyscall_windows.go
+++ b/src/internal/syscall/windows/zsyscall_windows.go
@@ -43,6 +43,7 @@ var (
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
procMoveFileExW = modkernel32.NewProc("MoveFileExW")
procGetACP = modkernel32.NewProc("GetACP")
+ procGetConsoleCP = modkernel32.NewProc("GetConsoleCP")
procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
)
@@ -84,6 +85,12 @@ func GetACP() (acp uint32) {
return
}
+func GetConsoleCP() (ccp uint32) {
+ r0, _, _ := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0)
+ ccp = uint32(r0)
+ return
+}
+
func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
nwrite = int32(r0)