Skip to content

Instantly share code, notes, and snippets.

@yancya
Last active December 19, 2015 12:29
Show Gist options
  • Save yancya/5955190 to your computer and use it in GitHub Desktop.
Save yancya/5955190 to your computer and use it in GitHub Desktop.
PDF における 16進数表記の文字列のデコード... もっと簡単にやれないのかね...
"8A4682B382F182B182F182C982BF82CD".
split("").
each_slice(2).
map{|a| a.join.hex}.
each_slice(2).
map{|a| a.pack("c*").encode("utf-8", "Shift_JIS")}.
join
@yancya
Copy link
Author

yancya commented Jul 11, 2013

元々のエンコードが Shift_JIS の場合はこれでいいんだけど、エンコードが Identity-H とかだと、4Byte ずつの 16進数 CID なので、CID2Unicode の仕組みが必要になる。なんてこった...

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