代码拉取完成,页面将自动刷新
package eventlogging
import (
"fmt"
"strings"
"unicode/utf16"
)
// UTF16BytesToString returns the Unicode code point sequence represented
// by the UTF-16 buffer b.
func UTF16BytesToString(b []byte) (string, int, error) {
if len(b)%2 != 0 {
return "", 0, fmt.Errorf("Slice must have an even length (length=%d)",
len(b))
}
offset := len(b)/2 + 2
s := make([]uint16, len(b)/2)
for i := range s {
s[i] = uint16(b[i*2]) + uint16(b[(i*2)+1])<<8
if s[i] == 0 {
s = s[0:i]
offset = i*2 + 2
break
}
}
return string(utf16.Decode(s)), offset, nil
}
// RemoveWindowsLineEndings replaces CRLF with LF and trims any newline
// character that may exist at the end of the string.
func RemoveWindowsLineEndings(s string) string {
s = strings.Replace(s, "\r\n", "\n", -1)
return strings.TrimRight(s, "\n")
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。