lib/writeexcel/helper.rb in writeexcel-0.4.0 vs lib/writeexcel/helper.rb in writeexcel-0.4.1
- old
+ new
@@ -19,5 +19,24 @@
end
end
str
end
private :convert_to_ascii_if_ascii
+
+
+ def utf8_to_16be(utf8)
+ utf16be = NKF.nkf('-w16B0 -m0 -W', utf8)
+ utf16be.force_encoding('UTF-16BE')
+ end
+ private :utf8_to_16be
+
+ def utf8_to_16le(utf8)
+ utf16le = NKF.nkf('-w16L0 -m0 -W', utf8)
+ utf16le.force_encoding('UTF-16LE')
+ end
+ private :utf8_to_16le
+
+ def ascii_to_16be(ascii)
+ ascii.unpack("C*").pack("n*")
+ ascii.force_encoding('UTF-16BE')
+ end
+ private :ascii_to_16be