Created
December 9, 2013 14:44
-
-
Save border/7873293 to your computer and use it in GitHub Desktop.
mahonia 默认没有支持GB2312编码, 但是支持GBK, 由于GBK编码完全兼容GB2312, 自己在GBK的代码里面注册一个GB2312就可以完美支持了. https://code.google.com/p/mahonia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~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) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment