[eluser]tinawina[/eluser]
Ok -
I have a form that has worked flawlessly for years. Now we are allowing people to add text to our database that might include characters with accents (eg., ñ instead of n; ó instead of o). In the end, what we want to do is translate these diacritics into HTML characters -- so, for example, ü gets changed to ü
For some reason (help) I can't get the input into the system without a weird character translation happening. Here's an example:
Input entered into the form (just words with diacritics included):
Code:
años son sobresalientes sólo existía un puñado
Echoing this form POST data, I get this weird garbled stuff back:
Code:
años son sobresalientes sólo existÃa un puñado
Here's some info about my form file:
Quote:The header includes
Code:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
The form tag looks like this:
Code:
<form id="add_title" action="/searchTitles" method="post" accept-charset="utf-8">
The input element:
Code:
<input type="text" name="title" id="title" accept-charset="utf-8" size="75" value="" />
Ultimately I would use a small script that checks for diacritics and changes them on the fly -- what shows below has been tested and works great.
Code:
$search = explode(",","À,È,Ì,Ò,Ù,à,è,ì,ò,ù,Á,É,Í,Ó,Ú,Ý,á,é,í,ó,ú,ý,Â,Ê,Î,Ô,Û,â,ê,î,ô,û,Ã,Ñ,Õ,ã,ñ,õ,Ä,Ë,Ï,Ö,Ü,Ÿ,ä,ë,ï,ö,ü,ÿ");
$replace = explode(",","À,È,Ì,Ò,Ù,à,è,ì,ò,ù,Á,É,Í,Ó,Ú,Ý,á,é,í,ó,ú,ý,Â,Ê,Î,Ô,Û,â,ê,î,ô,û,Ã,Ntilde;,Õ,ã,ñ,õ,Ä,Ë,Ï,Ö,Ü,Ÿ,ä,ë,ï,ö,ü,ÿ");
$new_input = str_replace($search, $replace, $string);
But my point is something is happening
before I can even get my "hands" on this form input to change an accented letter because it is coming to me in the POST data as garbled up.
Any help, insight, ideas - appreciated!