[Rails] Re: Character encoding problems.
Perry Smith wrote in post #1020442:
> I've been fighting these problems since I moved to Ruby 1.9. I am now
> using Ruby 1.9.2 with Rails 2.3.11 and I am still having problems. The
> symptom is errors with this message:
>
> (incompatible character encodings: UTF-8 and ISO-8859-1)
>
> I've marked all my files with:
>
> # -*- coding: utf-8 -*-
>
All that does is tell ruby that the strings in your source code should
be interpreted as utf-8. Here is an example:
if data == "€" #That's a euro symbol
...
By default strings in ruby source code are ASCII.
> and I've tried doing everything I can to try and get everything to be
> UTF-8 but I still have other character sets -- sometimes ISO-8859-1 as
> in this case, other ties it is ASCII-8BIT. These errors usually happen
> in the views as the various parts are being concatenated together.
>
> I need a general approach to these problems.
There is none. The bottom line is you have to know the encoding of any
data you read into your program. You can try to guess at an encoding,
but whether that works is hit and miss
Writing programs that handle anything but ascii data is hard. But the
world isn't an ascii world, so you have to adapt. Nevertheless, ruby's
handling of utf-8 is broken in so many places, it's astonishing.
Hopefully, it will get better. Some people are sticking with ruby 1.8.6
until things get better--but it will never be the case anymore that you
can assume that all data is ascii.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home