ANSI - UTF-8 conversion problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sangoku
Forum Newbie
Posts: 10
Joined: Wed Dec 02, 2009 10:48 am

ANSI - UTF-8 conversion problems

Post by sangoku »

Hy i have a lithe problem. I am making multiple files which are saved in utf-8 format and i have some leathers in them which are not part of the standard English alphabet.
My question IS WHY the hell when i call the file with include once in a php file which is in ANSI code the signs get screwed up in Mozilla Firefox but work fine in IE on windows 7!!!!____????? :banghead:

The biggest nut cracker is that when i soecify the utf encoding in the header of the html content i get some screwy chars on the beginning of the file!!!!! :dubious: :dubious: :dubious:
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: ANSI - UTF-8 conversion problems

Post by Apollo »

sangoku wrote:My question IS WHY the hell when i call the file with include once in a php file which is in ANSI code
Note that PHP code typically uses ascii characters only, hence UTF-8 or Ansi encoding makes no difference (or, rather, does not apply, as PHP code is never displayed). Any non-ascii characters in strings can be considered binary, and will be outputted as such, so it'll depend on the html header you specify how they are to be interpreted or what encoding they represent.

With "is in ANSI code", do you mean it generates Ansi-encoded HTML content?
the signs get screwed up in Mozilla Firefox but work fine in IE on windows 7!!!!____?????
Apparently, one of them detects you have invalid content (e.g. header saying UTF-8, but content is not all valid UTF-8) and then guesses an alternative encoding.
The biggest nut cracker is that when i soecify the utf encoding in the header of the html content i get some screwy chars on the beginning of the file!!!!!
The php file where you are including from, I assume it outputs the beginning of the page? (inluding the HTML header that specifies the UTF-8 encoding).
Perhaps you erratically output some Ansi encoded content there?

By the way, there's Ansi and Ansi. If you convert Ansi encoded content to UTF-8, of course make sure you specify the correct Ansi codepage from which you're converting.
sangoku
Forum Newbie
Posts: 10
Joined: Wed Dec 02, 2009 10:48 am

Re: ANSI - UTF-8 conversion problems

Post by sangoku »

Is seems i did not explain it right. I get the folowing problem take the scenatio:


header.phpfile(which was written and saved as an utf-8 file (text file saved with encoding utf-8))
|
gets included in a file which is ANSI encoded and which is caled


AND i get an error with displaying the content correctly.


That is my rpblem is there a way to buypass it!!!???
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: ANSI - UTF-8 conversion problems

Post by Apollo »

Perhaps *I* did not explain it right :)

Encoding does not apply on PHP files. If you are saving one php file in UTF-8 encoding and another in Ansi encoding, how is the PHP-parser gonna tell the difference? It isn't. Whatever bytes are in your PHP file, are outputted as such. It depends on the HTML header you generate, how these bytes are to be interpreted and displayed in the visitor's browser.

Regarding your situation: what kind of content/charset metatag do you write in your HTML header? If UTF-8, then fix the PHP file with Ansi content to output UTF-8 instead. If Ansi, then fix the php with UTF-8 content (header.php, right?) to output Ansi content instead (the same Ansi codepage as specified in your html header).
sangoku
Forum Newbie
Posts: 10
Joined: Wed Dec 02, 2009 10:48 am

Re: ANSI - UTF-8 conversion problems

Post by sangoku »

I ahte to be right in my assuming,, :cry:

Ok thy for the help
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: ANSI - UTF-8 conversion problems

Post by Apollo »

OK, if you still have any trouble with it, just post the relevant part of the two involved php files here, and perhaps we can see what's wrong.
sangoku
Forum Newbie
Posts: 10
Joined: Wed Dec 02, 2009 10:48 am

Re: ANSI - UTF-8 conversion problems

Post by sangoku »

it is solved,


But it should be more mentioned because it souses major problems like when you already made 100+ php files which all need editing. :crazy: :banghead:

I spent a whole night correcting those errors. :dubious:
Post Reply