kodierer |
combining work, life and hobbies sometimes isn't easy... |
Processing unicode files in ruby always was a mystery to me, until i found out about internal and external encodings. In the project i work on we have some unicode files with a BOM, this is some example code on how to process them in ruby:
f = File.open(filename, "r:UTF-16LE:UTF-8") #external UTF-16LE, internal UTF-8
f.seek 2 #skip the unicode BOM
f.each_line { |line| puts line }
f.close