Files
VRCWT-OSC/internal/app/codepage_windows.go
messypy b25e002092
Some checks failed
build-windows-exe / build (push) Failing after 1m43s
Make log decoding build on non-Windows CI
2026-07-27 23:13:30 +09:00

38 lines
650 B
Go

//go:build windows
package app
import (
"syscall"
"unsafe"
)
func decodeWithCodePage(b []byte, codePage uint32) string {
if len(b) == 0 {
return ""
}
kernel32 := syscall.NewLazyDLL("kernel32.dll")
multiByteToWideChar := kernel32.NewProc("MultiByteToWideChar")
n, _, _ := multiByteToWideChar.Call(
uintptr(codePage),
0,
uintptr(unsafe.Pointer(&b[0])),
uintptr(len(b)),
0,
0,
)
if n == 0 {
return ""
}
buf := make([]uint16, n)
multiByteToWideChar.Call(
uintptr(codePage),
0,
uintptr(unsafe.Pointer(&b[0])),
uintptr(len(b)),
uintptr(unsafe.Pointer(&buf[0])),
uintptr(len(buf)),
)
return utf16ToString(buf)
}