# Solved: Character Encoding in WAMP (PHP, Apache, MySQL)



## spinster (May 17, 2011)

Ok. Here's a puzzle for you...

I'm developing web apps in WAMP env. My usual - and until now - working solution has been that I'll configure the .htaccess file where I'll set the default character set encoding to ISO-8895-1 (Latin 1).

That way I don't need to replicate the header and meta tags at all. The server side worries that. Until now it has been working just fine - no worries.

Couple of days ago I upgraded my html editor and kabooom! - The encoding went mad... If I'll keep my original .htaccess file with Latin 1 settings the ecodings are wrong. I can fixit by changing the browsers encoding to UTF-8!!! 'Course after refresh I'll see the wrong encodings again - allthough encoding is correct - the Latin 1?? If I'll change my .htaccess file so that I'll set the encoding to UTF-8 everything works just fine. 

How is this possible since UTF-8 doesn't have the same encodings than Latin 1??? Doesn't make any sense... Or am I missing something in big time?


----------



## tomdkat (May 6, 2006)

UTF-8 is a Unicode encoding where ISO-8895-1 isn't. Still, the HTML editor you're using shouldn't have any impact on the character encoding the web server is configured to support.

You should look at the HTML source in the browser to see what encoding info the browser is actually getting from the server. You might want to also install a "web developer" kind of browser add-on, like Firebug for Firefox, to get more info on what the server is sending the browser and what the browser is doing with that info.

Peace...


----------



## spinster (May 17, 2011)

Hello! Yes I agree what you are saying. That's why this is so odd... The server side .htaccess is working. I've verified that with different .php document but it's not working with another .php document and they are both coded in the same way. Page source and page info shows correct encodings but the other .php document doesn't show correctly with Latin 1 - unless I change the encoding from Latin 1 to UTF-8 - and the other does. Don't make any sense...


----------



## tomdkat (May 6, 2006)

Could you post the GENERATED HTML for each page, the one that renders correctly and the one that doesn't?

Peace...


----------



## spinster (May 17, 2011)

Unfortunately no. Not allowed =) But I can tell you this - in those files there isn't any character set/enocoding specifications. Only place where the encoding has been set is .htaccess file - for all the files. It works too. 100% sure of it.

I made an interesting observation... when I compared those two files with DiffMerge, I noticed that the other file shows incorrect character set whilst the other one shows as supposed to. So somehow this one file gets or sets the wrong character set! Yet if I'll look at these files via my html editor they both look alike - no character set deviations. Only in the browser and DiffMerge.

SOLVED:

For some reason my html editor DID SAVE the file in wrong character set/encoding value! What I did was I copied the code and paste it to empty notepad.txt file which I then saved as .php file with ANSI encoding (can be choosed when saving) and now it works like before html editor upgrade =)

Thanks for your effort anyway tomdkat =)


----------



## tomdkat (May 6, 2006)

Interesting. So, it appears the character encoding info embedded in the file, itself, was causing grief. Did the generated HTML have a line similar to this in the section:

I'm glad you got it figured out. Be sure to let the developer/vendor of the HTML editor you use know about this. 

Peace...


----------



## spinster (May 17, 2011)

Exactly so. I have previously - a long time ago - bumped into a similar kind of situation...

Well I did tried those meta tags also but it didn't made any difference. All my code is meta tag free -at least what comes to content/encoding stuff. 

This kind of situation is a bit challenging to find out since everything seems to be ok and there is no visible fault to be seen. Lucky for me I did the file comparison with DiffMerge which revelead the incorrect character set.

Yep, I let them know =)


----------

