Last active
December 19, 2015 12:29
-
-
Save yancya/5955190 to your computer and use it in GitHub Desktop.
PDF における 16進数表記の文字列のデコード... もっと簡単にやれないのかね...
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
"8A4682B382F182B182F182C982BF82CD". | |
split(""). | |
each_slice(2). | |
map{|a| a.join.hex}. | |
each_slice(2). | |
map{|a| a.pack("c*").encode("utf-8", "Shift_JIS")}. | |
join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
元々のエンコードが Shift_JIS の場合はこれでいいんだけど、エンコードが Identity-H とかだと、4Byte ずつの 16進数 CID なので、CID2Unicode の仕組みが必要になる。なんてこった...