From: Luciano Ramalho Date: 2006-12-16T10:37:48+09:00 Subject: Re: newb: Rails character encoding and validation It is not really viable to validade a name field with a regex if youare willing to accept Unicode characters. The only reasonablevalidation is to check whether the field is empty. As for the testing, you'll have to configure your editor and yourterminal to the same encoding to get consistent results. UTF-8 is thebest bet, as it is also a W3C standard that every modern browsersupports. Cheers, Luciano On 12/15/06, Mark wrote:> 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.>>