Member Avatar

Hi all. Having more problems with utf-8 and Iñtërnâtiônàlizætiøn.

I'm running php (xampp) on Windows 7 (but it's also happening on my remote Linux site) and keep on getting nonsense with non-ASCII chars when they come from include files, e.g.

INCLUDE FILE: 'inc.php'

$simple = "Iñtërnâtiônàlizætiøn";


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" dir="ltr" lang="cy-GB" xml:lang="cy-GB">
<meta name="language" content="Welsh" />
<meta http-equiv="Content-Language" content="cy-GB" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
echo $simple . "";
echo "Straight: Iñtërnâtiônàlizætiøn";

I get this:

I've tried putting the utf-8 header in various placed to no avail.

Has anybody seen this before or got an idea? I've been searching for days now. I think I'm going bonkers.

//EDIT - all pages are save as UTF-8 without BOM.

Recommended Answers

All 6 Replies

It tests perfect here. It's got to be a server directive. Do you have root or equivalent access to the server?

Member Avatar

Hmmm. I'll have a look. Thanks for the quick reply.

I' think I've cracked it, the original include file was an ANSI, but I changed it to a UTF-8 without BOM. Unfortunately, I didn't check the state of the non-ansi chars as I was using a different editor. Blast. What a fool.

I'm gonna do some more digging, but I bet that's the problem.


Yes that was it. I copied the text from the editor pasted it into Notepad++ and saved as UTF-8 without BOM and now it's perfect.
Can't believe I fell into that. ANyway, thanks tinymark, it was good to know that the 'norm' worked and that it wasn't some weirdness from php itself.

Member Avatar

Didn't get it, you wanna echo those danish characters? If so I think you should write

&Oslash; instead of Ø
&aelig; instead of æ

google for this.
And this line may help

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Member Avatar

No that's HTML. I was dealing with php. If you write in a non-English language, using html encoding will drive you insane.

If you write in a non-English language, using html encoding will drive you insane.

me too I have this problems all the time

Member Avatar

> me too I have this problems all the time

Use a string file with an array of statements. As most of my sites are bi/multi-lingual, this is the only sane way to go (unless you use gettext or similar).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.