Hi, I'm having problems with special characters not showing on the webpage I'm working on.
It doesn't seem to want to work no matter what I try.

I'm pretty sure UTF-8 SHOULD show German, so I don't know what it is.


http://www.p-soldiers.com/ge/germanabout.php

Here's what I have on the page:

<link type="text/css" href="../main.css" rel="stylesheet" title="menu" charset "UTF-8">

CSS

@charset "UTF-8";

php.info

default_charset = utf-8

.htaccess

AddCharset UTF-8 .html .php

I checked this particular page to make sure I had saved it in UTF-8 and made sure the characters weren't corrupted in the document when I opened it, and it appears to be fine.
http://www.p-soldiers.com/ge/germanabout.php

I contacted tech support for my host and they say it's not a problem on their side. How can I fix this? Please help! :(

Recommended Answers

All 15 Replies

Member Avatar for diafol

do you need to use a dtd like xhtml?

My other website is in Japanese (same host) and I never did anything like that.

What IDE did you use for coding PHP? This may relate with the format how you save this file. Open your PHP file with text editor, notepad is the best in this case. Click 'file' and choose 'Save as'. Then select 'UTF-8' in the Encoding option, and then click OK.

Upload this file to server (overriding is ok) and refresh your web server and clear all cache. Then, reload this page on your browser.

Hope this help.

Yeah, when I wasn't getting it to work before I saved it in UTF-8 and re-uploaded it, but it didn't make any difference.
I've been concentrating on figure out how to fix this one page first so I've been checking everything on it.

looked at the page source as did the op, the text is served properly, perhaps this last in the chain of declarations broke the chain, showing charset[blank] <link type="text/css" href="../main.css" rel="stylesheet" title="menu" charset "UTF-8"> should it be ?? <link type="text/css" href="../main.css" rel="stylesheet" title="menu" charset="UTF-8"> ,

my translation from Anglais to French is in Canada, plenty of Francophones happy to explain all the accents, and the difference in meaning getting them wrong can make, to an 'import', and to implement it, and proof read, no thought required
this is fascinating

I honestly had to look several times until I realized that an = was missing! So I just went and fixed that now. Unfortunately, it's still not working :(

I checked in IE9 and Firefox just to make sure. This is very perplexing.

I just bugged around, changed the encoding to western European ISO, and western Europena Windows,
and the bent B,
o with dots
U with dots
(sorry I have heard of umlaughts and greve but I dont know which they ARE) all the characters that were blocks appeared
are you sure the file is encoded as UTF-8, my hex viewer is showing only single bytes for those characters that use 2bytes to display in utf-8

Member Avatar for diafol

OK, had a look at your various lang pages.

You don't have a DTD. Try replacing your head with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>...</title>

...(Css refs)...

</head>

I just tried your original (lack of DTD) with your text and umlauted characters and got rubbish output. I tried it with my DTD example and it worked fine. You may need to clear the IE cache to see the difference though.

BTW, if using xhtml, ALL tags should be lower case. This is important for the </body> and </html> tags at the end if you use the <html...> and <body> at the start.

You've probably triggered quirksmode without a DTD. I don't know if this applies the default encoding though.

The Spanish pages work as it seems you've html-encoded the text.

I tried copying and pasting that, and went through and lower-cased the tags, but the letters still aren't showing up and now the page is all jumbled.

I can HTML-encode all the text but it would be nice to just get it to work.

definitely not saved in utf-8

-d 340 5e0

0B39:0340 20 76 65 72 6C 69 65 72-65 6E 2E 0D 0A 44 69 65 verlieren...Die
0B39:0350 20 52 65 69 73 65 20 6B-6F 6D 6D 74 20 73 63 68 Reise kommt sch
0B39:0360 6E 65 6C 6C 20 76 6F 6D-20 57 65 67 20 61 62 2C nell vom Weg ab,
0B39:0370 20 77 65 6E 6E 20 64 69-65 20 45 69 6E 68 65 69 wenn die Einhei
0B39:0380 74 20 61 75 66 20 DC 62-65 72 72 65 73 74 65 20 t auf.berreste
0B39:0390 65 69 6E 65 73 20 52 61-75 6D 73 63 68 69 66 66 eines Raumschiff
0B39:03A0 73 20 73 74 F6 DF 74 20-75 6E 64 20 64 61 72 69 s st..t und dari
0B39:03B0 6E 2C 20 65 69 6E 20 4D-65 6E 73 63 68 2E 20 44 n, ein Mensch. D
0B39:03C0 69 65 20 65 72 73 63 68-72 65 63 6B 65 6E 64 65 ie erschreckende
0B39:03D0 20 45 6E 74 64 65 63 6B-75 6E 67 20 62 72 69 6E Entdeckung brin
0B39:03E0 67 74 20 49 68 6E 65 6E-20 73 6F 77 6F 68 6C 20 gt Ihnen sowohl
0B39:03F0 42 65 6C 6F 68 6E 75 6E-67 20 61 6C 73 20 61 75 Belohnung als au
0B39:0400 63 68 20 50 72 6F 62 6C-65 6D 65 2C 20 77 65 6E ch Probleme, wen
0B39:0410 6E 20 73 69 65 20 6D 69-74 20 66 65 69 6E 64 73 n sie mit feinds
0B39:0420 65 6C 69 67 65 6E 20 66-72 65 6D 64 65 6E 20 53 eligen fremden S
0B39:0430 6F 6C 64 61 74 65 6E 20-7A 75 73 61 6D 6D 65 6E oldaten zusammen
0B39:0440 6B 6F 6D 6D 65 6E 2C 20-64 69 65 20 41 6E 73 70 kommen, die Ansp
0B39:0450 72 75 63 68 20 61 75 66-20 64 69 65 20 61 75 DF ruch auf die au.
0B39:0460 65 72 69 72 64 69 73 63-68 65 6E 20 47 65 67 65 erirdischen Gege
0B39:0470 6E 73 74 E4 6E 64 65 20-65 72 68 65 62 65 6E 2E nst.nde erheben.
0B39:0480 20 44 61 72 75 6D 20 62-65 6D FC 68 74 20 69 68 Darum bem.ht ih
0B39:0490 72 65 20 4D 69 73 73 69-6F 6E 20 66 6F 72 74 7A re Mission fortz
0B39:04A0 75 73 65 74 7A 65 6E 2C-20 68 61 62 65 6E 20 64 usetzen, haben d
0B39:04B0 69 65 20 53 6F 6C 64 61-74 65 6E 20 6D 69 74 20 ie Soldaten mit
0B39:04C0 73 65 65 6C 69 73 63 68-65 6E 20 54 72 61 75 6D seelischen Traum
0B39:04D0 65 6E 2C 20 64 75 62 69-6F 73 65 6E 20 42 65 7A en, dubiosen Bez
0B39:04E0 69 65 68 75 6E 67 65 6E-20 75 6E 64 20 77 61 63 iehungen und wac
0B39:04F0 68 73 65 6E 64 65 6E 20-5A 77 65 69 66 65 6C 6E hsenden Zweifeln
0B39:0500 20 FC 62 65 72 20 64 65-6E 20 5A 77 65 63 6B 20 .ber den Zweck
0B39:0510 64 65 72 20 4D 69 73 73-69 6F 6E 20 7A 75 20 6B der Mission zu k
0B39:0520 E4 6D 70 66 65 6E 2E 20-0D 0A 0D 0A 54 68 69 73 .mpfen. ....This
0B39:0530 20 63 6F 6D 69 63 20 77-69 6C 6C 20 63 6F 6E 74 comic will cont
0B39:0540 61 69 6E 20 6D 61 74 75-72 65 20 63 6F 6E 74 65 ain mature conte
0B39:0550 6E 74 20 61 6E 64 20 74-68 65 6D 65 73 20 74 68 nt and themes th
0B39:0560 61 74 20 61 72 65 6E 27-74 20 73 75 69 74 61 62 at aren't suitab
0B39:0570 6C 65 20 66 6F 72 20 61-6C 6C 20 61 75 64 69 65 le for all audie
0B39:0580 6E 63 65 73 2E 20 49 66-20 79 6F 75 20 6D 61 79 nces. If you may
0B39:0590 20 62 65 20 74 72 69 67-67 65 72 65 64 20 62 79 be triggered by
0B39:05A0 20 76 69 6F 6C 65 6E 74-20 6F 72 20 73 65 78 75 violent or sexu
0B39:05B0 61 6C 20 63 6F 6E 74 65-6E 74 2C 20 70 6C 65 61 al content, plea
0B39:05C0 73 65 20 63 6C 6F 73 65-20 79 6F 75 72 20 62 72 se close your br
0B39:05D0 6F 77 73 65 72 20 6E 6F-77 2E 20 06 96 90 00 00 owser now. .....
0B39:05E0 E8 .
-q

the high order bytes should be delivered as two-byte codes, hex 80 and hex whatever
saved in ANSI

I was thinking about it and I realized that I saved germanabout.php in UTF-8, but I didn't save _top.txt, _middle.txt and _bottom.txt in UTF-8, and I thought maybe that could cause it. I went back and saved them all in UTF-8, and I deleted germanabout.php and saved a new file in UTF-8 just in case. That doesn't seem to have made any difference though.

Member Avatar for diafol

I've probably got you in a mid-edit stage, as the German/English version is totally mashed compared to the Spanish. Overlapping elements.

I don't really understand why you've got 3 different static text files going into one php page as you don't seem to be using a templating system, as /en/..., /sp/..., and /ge/... seem to be folders for unique pages.

Using a templating engine like RainTPL, smarty etc could make it even easier to maintain. I you'd like more info on this, let me know.


Try a trial php file.

Put a dtd with UTF-8 encoding in head
Put text directly into php file (german with umlauts)
view it in browsers.

Make sure this is saved as UTF-8 without BOM (Notepad++ will do this)

It's a template I created specifically for this comic. It's in multiple pages and every language will use the same code, so I don't have to re-do the code for every single comic page in every language. This is a bit more important when I actually get around to putting up the comic. But all of that works how I want it to; the only problem I'm having is the characters not showing up.

Putting in that code is what caused it to get all jumbled up; it doesn't do that without it. I made another simple HTML page with it here
http://www.p-soldiers.com/ge/german.html

The letters show up there, so it doesn't look like it's Notepad that's doing it.
But I need it to work with the php files.

Hmmm have you checked the options of your editor? Sometimes it's just a matter of how you save your files.

gonna say it again, dont shoot me,
the file is not saved in UTF-8
the hexdump prior post, shows characters higher than hex80, utf represents those as two byte characters, the slightly bold in the quote
listed again DC (= 80 5c)
F6 (= 80 76)
DF DF E4 FC FC E4 E8

are not present in a utf-8 file
the editor used to write the text is still saving in ansi, western Euro,

commented: brilliant, as usual AB. I missed it first time as I didn't understand it. Doh! +13
Be a part of the DaniWeb community

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