-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/text/encoding/traditionalchinese: wrong coding mapping #21910
Comments
Does a grep of the following files clarify anything? encoding/simplifiedchinese/tables.go encoding/traditionalchinese/tables.go |
Sorry, my english is very poor. |
% grep A55D golang.org/x/text/encoding/traditionalchinese/tables.go Try substituting the character "馬". |
package main
import (
"bytes"
"fmt"
"log"
"unicode/utf8"
"golang.org/x/text/encoding/traditionalchinese"
)
func main() {
src := []byte{165, 93} //big5 : 包
// big5 to utf8
b1, err := traditionalchinese.Big5.NewDecoder().Bytes(src)
if err != nil {
log.Fatalln(err)
}
r, _ := utf8.DecodeRune(b1)
fmt.Printf("包 unicode:0x%X big5:0x%X\n", r, src)
// utf8 to big5
b2, err := traditionalchinese.Big5.NewEncoder().Bytes(b1)
if err != nil {
log.Fatalln(err)
}
// not equal
fmt.Println(src, b2, bytes.Equal(src, b2))
fmt.Println("--------------------------")
src = []byte{176, 168} //big5 : 馬
// big5 to utf8
b1, err = traditionalchinese.Big5.NewDecoder().Bytes(src)
if err != nil {
log.Fatalln(err)
}
r, _ = utf8.DecodeRune(b1)
fmt.Printf("馬 unicode:0x%X big5:0x%X\n", r, src)
// utf8 to big5
b2, err = traditionalchinese.Big5.NewEncoder().Bytes(b1)
if err != nil {
log.Fatalln(err)
}
// equal
fmt.Println(src, b2, bytes.Equal(src, b2))
}
|
Have you read this? |
There's a "big5" thread here. https://lists.w3.org/Archives/Public/public-webapps-github/2016Oct/0063.html |
CC @mpvl |
包 bag |
Fixes #43581 |
What version of Go are you using (
go version
)?What did you do?
What did you expect to see?
What did you see instead?
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
@mpvl
The text was updated successfully, but these errors were encountered: