Page 1 of 1

problems with Umlaut !?

Posted: Thu Sep 12, 2002 3:32 pm
by dkizerian
Hi, I am having problems with Umlauts (Ö,ö) being used by people filling in information on a form. Is there an easy way to catch these and convert them to their respective non-umlauted Vowels?
:?:
Thanks
Dave K
SLC Utah

Posted: Thu Sep 12, 2002 3:58 pm
by dusty
i don't believe there is a built in function to do that.. you'll probably have to do it manually :\ what exactly is the problem you're having?

Posted: Thu Sep 12, 2002 4:09 pm
by hob_goblin
try something like

Code: Select all

$bad = array("Ö", "ö", "ô");
$good = array("O", "o", "o");
$string = str_replace($bad, $good, $string);

Posted: Thu Sep 12, 2002 5:20 pm
by dusty

Code: Select all

<?
function convert($str) {
  $str = htmlentities($strї0]);
  return $strї1];
}
echo preg_replace_callback("/ї\xC0-\xFF]/",convert,$str);
?>
will replace hex xC0 through xFF which covers all of the characters including umlauts, accents etc.

http://www.htmlhelp.com/reference/html4 ... atin1.html is the site i used with all of them listed with their hex incase you want to single out chars.

Posted: Thu Sep 12, 2002 5:49 pm
by hob_goblin
nice one, dusty. :lol:

Posted: Thu Sep 12, 2002 5:52 pm
by dkizerian
Thanks, between your help, and looking at a similar function I made years ago in javascript I was able to get it working the way I wanted

Posted: Fri Sep 13, 2002 10:20 am
by volka
htmlentites() converts ä ö ü as well to $auml; ...

Posted: Fri Sep 13, 2002 11:38 am
by dusty
that's all my script is doing, but rather than printing the full entity; it's grabbing the second letter which is always the normal letter (a, o, u, etc).

Posted: Fri Sep 13, 2002 4:28 pm
by Takuma
htmlentites() is porbably faster... Cos it doesn't need to load Perl Reg Expression module.

Posted: Fri Sep 13, 2002 5:16 pm
by dusty
hmm.. read the first post. he wants to change each umlaut to it's respective vowel. using htmlentities just changes it to just that.. an entity ie: Ä = &Auml

the preg function is locating the characters then sending it to the function that uses htmlentities to grab the 2nd letter of the output which in the example used above would be A.

if there is a way to do that with only htmlentities() please explain.

Posted: Sat Sep 14, 2002 1:00 am
by Takuma
OK, so there isn't a way to do it except using str_replace or preg_replace or ereg_replace then...