Skip to content
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

Decode GB2312 Got a panic #5

Closed
GoogleCodeExporter opened this issue Jun 23, 2015 · 1 comment
Closed

Decode GB2312 Got a panic #5

GoogleCodeExporter opened this issue Jun 23, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

I try to decode a GB2312, got a panic error.

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x697f2]

goroutine 1 [running]:
runtime.panic(0x20b320, 0x570cd9)
    /Users/Hong/go/src/pkg/runtime/panic.c:266 +0xb6
code.google.com/p/mahonia.Decoder.ConvertString(0x0, 0xc210045460, 0xda, 
0xc210045460, 0xda)
    /Users/Hong/gocode/src/code.google.com/p/mahonia/convert_string.go:41 +0xd2
main.fetch(0xc21000af80, 0xc21000aef0, 0xc210045460, 0xda)


------------------------
GB2312 (1980) has been superseded by GBK and GB18030 ([2]). So I register the 
GB2312 charset in gbk.go file.
Now It's work fine for me.

 ~GOPATH/src/code.google.com/p/mahonia hg diff 
diff -r 420ce60cb671 gbk.go
--- a/gbk.go    Fri Jul 19 13:15:30 2013 -0700
+++ b/gbk.go    Mon Dec 09 22:27:42 2013 +0800
@@ -12,6 +12,15 @@
            return encodeGBKRune
        },
    })
+   RegisterCharset(&Charset{
+       Name: "GB2312",
+       NewDecoder: func() Decoder {
+           return decodeGBKRune
+       },
+       NewEncoder: func() Encoder {
+           return encodeGBKRune
+       },
+   })
 }

 func decodeGBKRune(p []byte) (r rune, size int, status Status) {



----------
[1]: http://en.wikipedia.org/wiki/GBK
[2]: http://en.wikipedia.org/wiki/GB2312

Original issue reported on code.google.com by bord...@gmail.com on 9 Dec 2013 at 2:33

@GoogleCodeExporter
Copy link
Author

I added GB2312 as an alias for GBK, instead of as a separate charset with the 
same encoding.

Original comment by andybalholm@gmail.com on 11 Dec 2013 at 5:05

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant