My program file is encoded in UTF-8 so "abc".length == 3
but "åäö".length == 6
. I realize that å, ä, ö, etc. are stored as two bytes in UTF-8, and that a Ruby String is a sequence of bytes (not characters), but it is annoying! Is there a best practice to work around this problem?
views:
125answers:
2
A:
Hi Ragnarius,
Just add this command on the top of your file:
# -*- encoding: utf-8 -*-
Hope this helps.
Cyril
2010-03-27 19:12:06
Thanks but I still get "åäö".length==6
ragnarius
2010-03-27 20:21:18
I think the best way is to update.
Cyril
2010-03-28 10:30:59
That won't work for 1.8 afaik.
khelll
2010-03-30 22:00:45