1 Star 0 Fork 0

GZCorrect/go-smpp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ucs2.go 800 Bytes
一键复制 编辑 原始数据 按行查看 历史
xiegongming 提交于 3个月前 . 合并
// Copyright 2015 go-smpp authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package pdutext
import (
"golang.org/x/text/encoding/unicode"
"golang.org/x/text/transform"
)
// UCS2 text codec.
type UCS2 []byte
// Type implements the Codec interface.
func (s UCS2) Type() DataCoding {
return UCS2Type
}
// Encode to UCS2.
func (s UCS2) Encode() []byte {
e := unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM)
es, _, err := transform.Bytes(e.NewEncoder(), s)
if err != nil {
return s
}
return es
}
// Decode from UCS2.
func (s UCS2) Decode() []byte {
e := unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM)
es, _, err := transform.Bytes(e.NewDecoder(), s)
if err != nil {
return s
}
return es
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gzcorrect/go-smpp.git
git@gitee.com:gzcorrect/go-smpp.git
gzcorrect
go-smpp
go-smpp
v0.0.3

搜索帮助

371d5123 14472233 46e8bd33 14472233