Skip to content

Instantly share code, notes, and snippets.

@chitoku-k
Created March 25, 2024 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chitoku-k/3dbb2a8054dfef54c9d7e849949178d3 to your computer and use it in GitHub Desktop.
Save chitoku-k/3dbb2a8054dfef54c9d7e849949178d3 to your computer and use it in GitHub Desktop.
Create a file with its filename including an ill-formed UTF-16 on Windows
package main
import (
"fmt"
"golang.org/x/sys/windows"
)
func main() {
filename := []uint16{0xD800, 0x00}
hWnd, err := windows.CreateFile(
&filename[0],
windows.GENERIC_READ|windows.GENERIC_WRITE,
uint32(0),
nil,
windows.CREATE_NEW,
windows.FILE_ATTRIBUTE_NORMAL,
windows.Handle(uintptr(0)),
)
fmt.Printf("hWnd: %+v\n", hWnd)
fmt.Printf("err: %+v\n", err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment