Page 1 of 1

ANSI - UTF-8 conversion problems

Posted: Wed Dec 02, 2009 10:56 am
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:

Re: ANSI - UTF-8 conversion problems

Posted: Wed Dec 02, 2009 11:39 am
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.

Re: ANSI - UTF-8 conversion problems

Posted: Wed Dec 02, 2009 11:51 am
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!!!???

Re: ANSI - UTF-8 conversion problems

Posted: Wed Dec 02, 2009 12:19 pm
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).

Re: ANSI - UTF-8 conversion problems

Posted: Thu Dec 03, 2009 10:10 am
by sangoku
I ahte to be right in my assuming,, :cry:

Ok thy for the help

Re: ANSI - UTF-8 conversion problems

Posted: Thu Dec 03, 2009 10:22 am
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.

Re: ANSI - UTF-8 conversion problems

Posted: Fri Dec 04, 2009 8:53 am
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: