Module: Excel::UnicodeUtils
- Included in:
- BiffRecord, SharedStringTable, SharedStringTable
- Defined in:
- lib/ru_excel/unicode_utils.rb
Instance Method Summary collapse
Instance Method Details
#u2bytes(str) ⇒ Object
49 50 51 |
# File 'lib/ru_excel/unicode_utils.rb', line 49 def u2bytes(str) Excel::ICONV[:to_unicode].iconv(str) end |
#u2ints(str) ⇒ Object
45 46 47 |
# File 'lib/ru_excel/unicode_utils.rb', line 45 def u2ints(str) Excel::ICONV[:to_unicode].iconv(str).unpack('S*') end |
#upack1(str) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/ru_excel/unicode_utils.rb', line 63 def upack1(str) begin ustr = Excel::ICONV[:check_ascii].iconv(str) [str.length, 0].pack('CC')+str rescue Iconv::IllegalSequence ustr = u2bytes(str) [ustr.length / 2, 1].pack('CC')+ustr end end |
#upack2(str) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/ru_excel/unicode_utils.rb', line 53 def upack2(str) begin ustr = Excel::ICONV[:check_ascii].iconv(str) [str.length, 0].pack('vC')+str rescue Iconv::IllegalSequence ustr = u2bytes(str) [ustr.length / 2, 1].pack('vC')+ustr end end |