Last active
December 10, 2015 18:28
-
-
Save rolfb/4474337 to your computer and use it in GitHub Desktop.
Example WriteExcel script with UTF-8 strings which doesn't work with jruby-1.7.2
Before running do "gem install writeexcel"
This file contains 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
# encoding: utf-8 | |
require 'writeexcel' | |
string_utf8 = "øæaaø" | |
string_no_utf8 = "abc" | |
excel = WriteExcel.new("out.xls") | |
ws = excel.add_worksheet | |
ws.write("A1", string_utf8) | |
ws.write("A2", string_no_utf8) | |
excel.close |
This file contains 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
# encoding: utf-8 | |
require 'nkf' | |
utf8 = "aæøåbøøc" | |
utf16le = NKF.nkf('-w16L0 -m0 -W', utf8) | |
utf16le.force_encoding('UTF-16LE') | |
puts RUBY_DESCRIPTION | |
puts utf16le |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment