From: "Johan Sörensen" Date: 2004-12-18T00:42:35+09:00 Subject: utf-8 & Range under eruby (possibly Rails) problems Hi, I'm having some issues with a range that truncates texts, the below is a (very) simplified version of the truncate method thats used in rails (which is where I discovered this): # this in an utf-8 encoded erb template (a rails "view" in my case) <% text = "Eftersom jag jobbar som kontrukt�r/ingenj�r p� dagarna och hackar cocoa" -%> <%= text[0..47] %>
<%= text[0..48] %>
# notice the 'o' in ingenjor instead of '�' <% othertext = "Eftersom jag jobbar som kontrukt�r/ingenjor p� dagarna och hackar cocoa" -%> <%= othertext[0..47] %> #produces this (the last character on the first line will display as a "funny character" in browsers) Eftersom jag jobbar som kontrukt�r/ingenj�r p? Eftersom jag jobbar som kontrukt�r/ingenj�r p� Eftersom jag jobbar som kontrukt�r/ingenjor p� Is this a possible bug in Ruby (1.8.1) or could it be something with Rails that gets in the way, I can reproduce this across two servers and in webrick. I was unable to do this properly in irb, since my terminal (or irb) would act funny on the ���'s.. --johan -- Johan S�rensen Professional Futurist www.johansorensen.com