Link to home
Start Free TrialLog in
Avatar of Poormandm
Poormandm

asked on

str_replace unicode Error

I try to convert string  to unicode but I can't save the script because the server doesn't run the code. The server display the whole script.

Please copy the text below into notepad or any text editor and save as something.php and please remember to pick the encoding option to be Unicode.


<?php

$a = "a` a('";
$a = str_replace(array("a`", "a('"), array("à ", "&#7855; "), $a);
echo $a;
?>
Avatar of hernst42
hernst42
Flag of Germany image

If you see the source of the file, then your webserver is not configured to execute php-scripts correctly. As long as the "<?php" is not encoded in unicode and your webserver is configured correctly you will not see the code of your script.
Avatar of Poormandm
Poormandm

ASKER

thanks
let me try to build the include file and include that file in to see if php server can understand it.
ASKER CERTIFIED SOLUTION
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

the à  is unicode
http://www.unicode.org/charts/

à á &#7845; &#417; &#7901; &#432; &#273;
experts-exchange.com change my unicode  to some strange numbers

the  &#7845 is actually the letter a( but the ( is on the top of the a.

That give me a hint, I should convert my unicode to ascii then use it.

Oh yes..

thanks

transfrom

a á à &#7841; &#7843; ã
&#259; &#7855; &#7857; &#7863; &#7859; &#7861;
â &#7845; &#7847; &#7853; &#7849; &#7851;
e é è &#7865; &#7867; &#7869;
ê &#7871; &#7873; &#7879; &#7875; &#7877;
u ú ù &#7909; &#7911; &#361;
&#432; &#7913; &#7915; &#7921; &#7917; &#7919;
i  í ì &#7883; &#7881; &#297;
o ó ò &#7885; &#7887; õ
&#417; &#7899; &#7901; &#7907; &#7903; &#7905;
ô &#7889; &#7891; &#7897; &#7893; &#7895;
&#273;

Hey! Glad to have helped. (Did I?).

What happens if you encode both pages as UTF-8? That SHOULD work better.