Closed
Description
What version of Go are you using (go version
)?
1.9
go get -u golang.org/x/text/
What did you do?
package main
import (
"fmt"
"log"
"unicode/utf8"
"golang.org/x/text/encoding/traditionalchinese"
)
func main() {
str := "包"
b, err := traditionalchinese.Big5.NewEncoder().Bytes([]byte(str))
if err != nil {
log.Fatalln(err)
}
r, _ := utf8.DecodeRuneInString(str)
fmt.Printf("unicode:0x%X big5:0x%X\n", r, b) //incorrect
}
What did you expect to see?
unicode:0x5305 big5:0xA55D
What did you see instead?
unicode:0x5305 big5:0xFABD
reference:
http://moztw.org/docs/big5/table/cp950-u2b.txt
http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT
https://encoding.spec.whatwg.org/index-big5.txt