Reputation: 115
This may be a stupid question but its not a matter of what I can find, its a matter that I dont know what to search for. There are some special characters that don't show correctly in php. I'm taking some information from an xml file, and echo-ing them.
ie:
should be -> Nürnberg
echoes as -> Nürnberg
any tips on what to look for, or how to resolve this?
Upvotes: 1
Views: 3108
Reputation: 25701
"I'm taking some information from an xml file, and echo-ing them."
Windows command line doesn't support utf8 properly as it doesn't use an UTF8 font.
Just put the file into somewhere that's reachable through a web server and test it by calling the file through the web server. Alternatively pipe the output of the script into a text file:
php test.php > output.txt
And either open output.txt is a UTF8 capable editor or use a utf8 capable 'Tail' program.
Test.php
<?php
echo "Nürnberg";
?>
Running from command prompt:
php test.php
Nürnberg
Calling through a web server http://localhost/test.php
Nürnberg
Upvotes: 0
Reputation: 522016
You simply have an encoding mismatch. Get up to speed with these articles:
What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text
Handling Unicode Front To Back In A Web App
Upvotes: 1
Reputation: 2555
There is a mismatch between the character encoding of your XML and what you are outputting from PHP. Most likely, one is UTF-8 and one is ISO-8859.
On the PHP side, you can set this with a header directive
<?php
header('Content-Type: text/plain; charset=ISO-8859-1');
header('Content-Type: text/plain; charset=utf-8');
?>
and/or in the outputted HTML
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
On the XML side, most quality text editors allow you to specify the character encoding as you save the file. (E.g. WordWrangler on Mac)
If the XML file is indeed in ISO-8859, you could use utf8_encode()
to convert it to UTF-8 as you read it in.
An in-depth discussion of PHP and character encoding.
Upvotes: 0
Reputation: 23231
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Upvotes: 1
Reputation: 6190
Can you try with following meta tag in your HTML head.
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
Upvotes: 0
Reputation: 2629
try a different character set on the page you're echoing from
http://www.w3schools.com/tags/ref_charactersets.asp
Upvotes: 0