Forum: Ruby on Rails iso-8859-1 no effect in browser

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
tivrfoa (Guest)
on 2009-05-26 08:40
(Received via mailing list)
hi folks!

I want to use characters with accent, like: é, ç, ã, ô. Then I changed
from UTF-8 to iso-8859-1, so I can use é direct, instead of é

<html>
<head>
  <meta http-equiv="content-type" content="text/
html;charset=iso-8859-1" />

The strange is that when I go in View -> Codification, it is marked
Unicode (UTF-8). :(
But this is not the worst. The browser doesn't change from special
chars to its meaning.

validates_format_of :email,
        :with =>
%r{[_a-z0-9-][_a-z0-9-]*@[_a-z0-9-][_a-z0-9-]*\.[_a-z0-9-]
[_a-z0-9-]*}i,
        :message => 'est&aacute; incorreto'

It display Email est&aacute; incorreto.
I want Email está incorreto.

Help meee! =D
Fidel V. (Guest)
on 2009-05-26 10:02
(Received via mailing list)
On Tue, May 26, 2009 at 5:39 AM, tivrfoa <removed_email_address@domain.invalid>
wrote:
>
> It display Email est&aacute; incorreto.
> I want Email está incorreto.
>
> Help meee! =D

Have you tested with utf-8? That should have worked.

Fidel.
Phlip (Guest)
on 2009-05-26 17:26
(Received via mailing list)
tivrfoa wrote:

> I want to use characters with accent, like: é, ç, ã, ô. Then I changed
> from UTF-8 to iso-8859-1, so I can use é direct, instead of &eacute;

That's not what the charset= is for. You should use the correct entities
if at
all possible, and neither your editor...

> The strange is that when I go in View -> Codification, it is marked
> Unicode (UTF-8). :(

...nor Ruby...

> validates_format_of :email,
>         :with => %r{[_a-z0-9-][_a-z0-9-]*@[_a-z0-9-][_a-z0-9-]*\.[_a-z0-9-]
> [_a-z0-9-]*}i,
>         :message => 'est&aacute; incorreto'

...are bothering to read that directive. They are still defaulting to
utf-8,
which is good enough for 99.999% of all programming.

Further, both utf-8 and iso-8859-1 share many of the same Latin-1 code
points,
including é. Utf-8 merely gives the additional abilities to build the é out
of
an e and a modifying accent character, and the ability to read and write
every
other glyph in the world.

You would only use iso-8859-1 if you had a database with known
iso-8859-1
strings, AND if you did not want to simply Iconv them to UTF-8 before
pushing
them into your HTML.

--
   Phlip
   http://twitter.com/Pen_Bird
tivrfoa (Guest)
on 2009-05-26 19:20
(Received via mailing list)
tks! it didn't work in utf-8. if I use está (without the special
character), it display an interrogation symbol (?)

Could someone try to use this => :message => 'est&aacute; incorreto'
in some validation to see if it works?

How can I display "está"?

tks
Franco C. (Guest)
on 2009-05-26 21:44
(Received via mailing list)
I create almost only spanish applications, all with Ñ ñ, á é and so
on, and use ONLY UTF-8.

The meta directive <meta http-equiv="Content-Type" content="text/html;
charset=utf-8" /> between the head tags does all the magic.

Regards.

Franco C..
tivrfoa (Guest)
on 2009-05-27 00:00
(Received via mailing list)
thansk Franco.

it works on the view, but not work in the model (at least here)
did you try to add a message in some model with accent?
Franco C. (Guest)
on 2009-05-27 02:30
(Received via mailing list)
Yes, i use it a lot, but in this form:

record.errors.add attr, :invalid # or any other

And then in the config/locales/es.yml

es:
  activerecord:
    errors:
      messages:
        invalid: "no es válido"

      # Custom for one model
      models:
        somemoder:
          attributes:
            someattribute:
              invalid: "es inválido"

I never use it in the direct form, always with the I18n package. If
you want a complete example see
http://github.com/svenfuchs/rails-i18n/tree/master....

Regards.

Franco C..
tivrfoa (Guest)
on 2009-05-28 19:10
(Received via mailing list)
thanks folks.

I solved the problem using a different text editor. Now I'm using <a
href="http://plasmacode.com/">RoRED</a>. It's an amazing editor, but
only available for Windows.
The problem was the encode of the files.
This topic is locked and can not be replied to.