john
12/15/2006 7:47:00 PM
I'm putting together a basic rails application, and writing my first
units tests for it.. It occured to me that the user 'name' field might
want to contain foreign characters (like é,â,ì,ø... etc.) But two
problems have popped up. Firstly, I can't dig up a good reference for a
suitable regular expression for validating the field.
at the moment, I'm using:
validates_format of :name, :with => /^[-' a-zA-Z]+$/
but this isn't going to allow the foreign characters, so the test fails.
The second problem is the error message I get when I run the unit test:
My test framework sets the name to José, the the failure message when I
run the script returns JosÜ.
It looks like the character encoding of my editor isn't the same as the
character encoding that rails is using.
so, a) any clues as to what is going on? and b) is there a consistent
way of dealing with foreign characters for validation purposes?
Many thanks in advance!
Mark.