慕桂英4014372
// Alert: This is Windows-specific, uses undocumented methods, does not// handle stdout redirection, does not check for errors, etc.// Use at your own risk.// Tested with Go 1.0.2-windows-amd64.package mainimport "unicode/utf16"import "syscall"import "unsafe"var modkernel32 = syscall.NewLazyDLL("kernel32.dll")var procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")func consolePrintString(strUtf8 string) { var strUtf16 []uint16 var charsWritten *uint32 strUtf16 = utf16.Encode([]rune(strUtf8)) if len(strUtf16) < 1 { return } syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(syscall.Stdout), uintptr(unsafe.Pointer(&strUtf16[0])), uintptr(len(strUtf16)), uintptr(unsafe.Pointer(charsWritten)), uintptr(0), 0)}func main() { consolePrintString("Hello ☺\n") consolePrintString("éèïöîôùòèìë\n")}