Make log decoding build on non-Windows CI
Some checks failed
build-windows-exe / build (push) Failing after 1m43s

This commit is contained in:
messypy
2026-07-27 23:13:30 +09:00
parent dd165d9301
commit b25e002092
3 changed files with 57 additions and 33 deletions

View File

@@ -0,0 +1,37 @@
//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)
}