I have a simple script that reads a XML file and writes a CSV file. My scripts all have #encoding:utf-8 at the top and I explicitly set the external encoding on all reads and writes as UTF-8.
Everything works as expected.
I packaged my script using Warbler and deployed it to the network for my colleagues. Unfortunately the CSV files being generated by the packaged jar were incorrect -- various non-ASCII characters were being munged.
It took me a while to work out that the fix was to specify the file.encoding as a JVM option. E.g.
java -Dfile.encoding=UTF-8 -jar myscript.jar
In other words, there was differing behavior between my raw (j)ruby script and the Warbler package of same.
I'm not sure if this is a bug in Warbler, or JRuby, or not a bug at all, but I thought I'd post this here for discussion and in case somebody else has the same problem.
Luckily for me, I wanted UTF-8 all around. I don't know what I would do if I wanted a mixture of encodings among source files, input file and output file. Ruby would allow this, but how would I set file.encoding?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I have a simple script that reads a XML file and writes a CSV file. My scripts all have
#encoding:utf-8at the top and I explicitly set the external encoding on all reads and writes as UTF-8.Everything works as expected.
I packaged my script using Warbler and deployed it to the network for my colleagues. Unfortunately the CSV files being generated by the packaged jar were incorrect -- various non-ASCII characters were being munged.
It took me a while to work out that the fix was to specify the file.encoding as a JVM option. E.g.
In other words, there was differing behavior between my raw (j)ruby script and the Warbler package of same.
I'm not sure if this is a bug in Warbler, or JRuby, or not a bug at all, but I thought I'd post this here for discussion and in case somebody else has the same problem.
Luckily for me, I wanted UTF-8 all around. I don't know what I would do if I wanted a mixture of encodings among source files, input file and output file. Ruby would allow this, but how would I set file.encoding?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.