replacing umlauts (special chars) in strings
Posted: Mon Aug 07, 2006 1:33 pm
Hey boys and girls, I need a hand please!
I'm working on my cousins webpages on my spare time, and have been succesfull mostly. The pages are almost done, except for a minor bugger: the scandinavian umlauts (ä and ö) turn out corrupted. I believe the browser is responsible, cos when I look at the HTML source (in notepad) the umlauts show up just fine. So I tough the safest way would be to replace them umlauts with their HTML codes like ä and ö So I lifted some code from php.net:
But this doesn't appear to do anything, the letters still appear in their original form. I also tried a variation:
Without success. Maybe the problem is obvious... Maybe not? I came over from writing C and never really tried to use Finnish with my programs before...
Oh, and just for some background; I pick up the data from a form and simply write the entries into a txt file. And by directly looking at this file I can verify that the umlauts were not changed (also checked that the browser doesn't translate HTML codes when viewing txt files).
help much priciated!
I'm working on my cousins webpages on my spare time, and have been succesfull mostly. The pages are almost done, except for a minor bugger: the scandinavian umlauts (ä and ö) turn out corrupted. I believe the browser is responsible, cos when I look at the HTML source (in notepad) the umlauts show up just fine. So I tough the safest way would be to replace them umlauts with their HTML codes like ä and ö So I lifted some code from php.net:
Code: Select all
$trans = array('ä' => 'ä', 'Ä' => 'Ä', 'ö' => 'ö', 'Ö' => 'Ö');
$ctmp = strtr($_POST['comment'], $trans);Code: Select all
$trans = array("ä" => 'ä', "Ä" => 'Ä', "ö" => 'ö', "Ö" => 'Ö');
$ctmp = str_replace(array_keys($trans), $trans, $_POST['comment']);Oh, and just for some background; I pick up the data from a form and simply write the entries into a txt file. And by directly looking at this file I can verify that the umlauts were not changed (also checked that the browser doesn't translate HTML codes when viewing txt files).
help much priciated!