diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/decode-pdf-string | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/decode-pdf-string b/scripts/decode-pdf-string new file mode 100755 index 00000000..f4198ddf --- /dev/null +++ b/scripts/decode-pdf-string @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby + +str = ARGV[0] + +def string_object_to_utf16 str + [str.force_encoding(::Encoding::US_ASCII)].pack('H*').force_encoding ::Encoding::UTF_16BE +end + +def string_object_to_utf8 str + [str.force_encoding(::Encoding::US_ASCII)].pack('H*').force_encoding ::Encoding::UTF_8 +end + +def utf16_to_utf8 str + str.encode ::Encoding::UTF_8 +end + +def decode_hexified_utf16_string_object str + utf16_to_utf8 string_object_to_utf16 str +end + +def decode_hexified_utf8_string_object str + string_object_to_utf8 str +end + +if ARGV[1] == 'utf8' + puts decode_hexified_utf8_string_object ARGV[0].dup +else + puts decode_hexified_utf16_string_object ARGV[0].dup +end |
