1 Star 0 Fork 0

GZCorrect/go-smpp

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
ucs2.go 800 Bytes
Copy Edit Raw Blame History
xiegongming authored 2 months ago . 合并
// 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

Search