Source File
utf16le.go
Belonging Package
github.com/hirochachacha/go-smb2/internal/utf16le
package utf16le
import (
)
var (
le = binary.LittleEndian
)
func ( string) int {
:= 0
for , := range {
if 0x10000 <= && <= '\U0010FFFF' {
+= 4
} else {
+= 2
}
}
return
}
func ( []byte, string) int {
:= utf16.Encode([]rune())
for , := range {
le.PutUint16([2*:2*+2], )
}
return len() * 2
}
func ( string) []byte {
if len() == 0 {
return nil
}
:= utf16.Encode([]rune())
:= make([]byte, len()*2)
for , := range {
le.PutUint16([2*:2*+2], )
}
return
}
func ( []byte) string {
if len() == 0 {
return ""
}
:= make([]uint16, len()/2)
for := range {
[] = le.Uint16([2* : 2*+2])
}
if len() > 0 && [len()-1] == 0 {
= [:len()-1]
}
return string(utf16.Decode())
}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |