跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

strutil.go

28 行 · 799 B历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package strutil
5
6import (
7 "io"
8
9 "golang.org/x/text/encoding/unicode"
10 "golang.org/x/text/transform"
11)
12
13// FromUTF16le returns an io.Reader for UTF16le data.
14// Windows uses little endian by default, use unicode.UseBOM policy to retrieve BOM from the text,
15// and unicode.LittleEndian as a fallback.
16func FromUTF16le(r io.Reader) io.Reader {
17 return transform.NewReader(r, unicode.UTF16(unicode.LittleEndian, unicode.UseBOM).NewDecoder())
18}
19
20// FromUTF16leToString reads from Unicode 16 LE encoded data from an io.Reader and returns a string.
21func FromUTF16leToString(r io.Reader) (string, error) {
22 out, err := io.ReadAll(FromUTF16le(r))
23 if err != nil {
24 return "", err
25 }
26
27 return string(out), nil
28}