Created
May 21, 2009 17:18
-
-
Save ihower/115577 to your computer and use it in GitHub Desktop.
convert big5 hex codepoint to utf-8 string
This file contains hidden or 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
require 'iconv' | |
$KCODE = 'u' | |
hex_string ="4A6BA441" # A441 is big5 "乙" | |
big5_string = hex_string.scan(/../).map{ |c| c.hex }.pack("c*") | |
iconv = Iconv.new("utf-8//ignore", "big5") | |
utf8_string = iconv.iconv(big5_string) # convert to utf-8 | |
puts utf8_string # output JK乙 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment