mirror of
https://github.com/fumiama/go-base16384.git
synced 2026-06-24 05:18:32 +08:00
add free
This commit is contained in:
@@ -14,7 +14,7 @@ Turn the result to its original coding form to decode.
|
|||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
## As package
|
## As package
|
||||||
Just include it in your project.
|
Just import it in your project.
|
||||||
## As lib
|
## As lib
|
||||||
Copy this repo to `$GOPATH/src`, then execute
|
Copy this repo to `$GOPATH/src`, then execute
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
2
conv.go
2
conv.go
@@ -6,10 +6,12 @@ import (
|
|||||||
|
|
||||||
var format = unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM)
|
var format = unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM)
|
||||||
|
|
||||||
|
// UTF16be2utf8 to display the result as string
|
||||||
func UTF16be2utf8(b []byte) ([]byte, error) {
|
func UTF16be2utf8(b []byte) ([]byte, error) {
|
||||||
return format.NewDecoder().Bytes(b)
|
return format.NewDecoder().Bytes(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UTF82utf16be to decode from string
|
||||||
func UTF82utf16be(b []byte) ([]byte, error) {
|
func UTF82utf16be(b []byte) ([]byte, error) {
|
||||||
return format.NewEncoder().Bytes(b)
|
return format.NewEncoder().Bytes(b)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user