NYCPHP Meetup

NYPHP.org

[nycphp-talk] enforcing Latin-1 input

Allen Shaw ashaw at polymerdb.org
Mon Nov 21 17:38:01 EST 2005


Hi Folks,

I have an app that should be storing input only in Latin-1 characters, 
but which will probably be used by English-speaking individuals in Asia, 
Middle East, and other locales. I expect that some of those people will 
sometimes type input in their own local character set, but I really do 
not want to store information that I won't even be able to read later.

I've been reading around and have gotten more of an understanding of 
this issue lately, but still don't understand enough to filter user 
input to be sure it's in the Latin-1 character set. I tried using 
"accept-charset" attribute in <form> tag, and I also thought that at 
least MySQL would mangle input that's not Latin-1 on this database 
having a charset value of "Latin-1", but darnit, mysql is too good for 
me and stores and retrieves Korean and Japanese text without a hitch.

Naturally mangled input is not what I want, so I guess it's okay that 
mysql didn't destroy the data. :o) What I really want is that if 
$_POST['usertext'] == 大阪市浪速区のマンション [wow, how does that look 
in your mail reader?] then the app will know it and tell the user 
"please enter only characters in the Latin-1 set".

As usual, I'm sure I'm just not getting something basic here. Is this 
even possible?

-- 
Allen Shaw
Polymer (http://polymerdb.org)




More information about the talk mailing list