hi all,
I put a ° in a string but when I render it to the screen the ° changes
in <?> block. The rest of the string is renderen correctly.
How is this caused?
Thanks
Stijn
hi all,
I put a ° in a string but when I render it to the screen the ° changes
in <?> block. The rest of the string is renderen correctly.
How is this caused?
Thanks
Stijn
On 10/4/07, Tarscher [email protected] wrote:
hi all,
I put a � in a string but when I render it to the screen the � changes
in <?> block. The rest of the string is renderen correctly.How is this caused?
Sincerely,
Isak
On 10/4/07, Tarscher [email protected] wrote:
hi all,
I put a ° in a string but when I render it to the screen the ° changes
in <?> block. The rest of the string is renderen correctly.
By default, Rails tells the browser that the content type for your
pages is UTF-8. If your templates are using a different encoding, that
will cause the problem you’re seeing.
Many thanks for the reply. It’s still not clear thuogh.
My page that renders the questionmark has:
...Shouldn’t that be sufficient to render the exotic caracter?
Regards,
Stijn
On 10/8/07, Tarscher [email protected] wrote:
Many thanks for the reply. It’s still not clear thuogh.
My page that renders the questionmark has:
...Shouldn’t that be sufficient to render the exotic caracter?
No, not if the character is not actually UTF-8. Your editor has to be
saving as UTF-8 as well.
Let’s look at the “degree” character:
The Unicode code point is 0176 decimal (hex 00B0).
The Latin1 encoding is one byte: 0xB0
However, the UTF-8 encoding is two bytes: C2 B0
Now, suppose your editor is set to use Latin1. You will see a degree
character on the screen in your editor. When you save the file, the
editor will write this a a single 0xB0 byte (since that’s how you
represent this symbol in Latin1 encoding).
Now, when the template gets sent to the browser, you’ve told it that
you’re sending UTF-8. As the data is sent, the browser tries to
interpret the 0xB0 as a UTF-8 sequence and it gets confused, because
0xB0 is not a legal UTF-8 sequence. So, since it doesn’t know what
you’re trying to do, it shows a question mark or some other marker
character.
Make sense?
Tarscher wrote:
Many thanks for the reply. It’s still not clear thuogh.
My page that renders the questionmark has:
...Shouldn’t that be sufficient to render the exotic caracter?
Is the character in a variable or hardcoded in the template? If it’s
hardcoded, you need to ensure your editor is saving your template as
UTF-8. If it’s a variable, you need to ensure you have all the Ruby
I18N configuration set up correctly for UTF-8.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs