jimath Posted February 2, 2008 Share Posted February 2, 2008 hi everyone! i have a problem with charset. i am using php 4.3.4. in all my scripts i ve declared the line <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> i put UTF-8 from character encoding in mozzila browser and when i click a link in my project the letters are changed to sth unintelligible. could anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/ Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 What is unintelligible - text pulled from a database, or text hardcoded into your php documents? Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456124 Share on other sites More sharing options...
jimath Posted February 2, 2008 Author Share Posted February 2, 2008 no, the problem is that the character encoding in mozilla changes when i click a link in my page. Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456126 Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 On the page you are looking at, or the page you go to? It sounds like the output encoding of PHP may not be set to utf-8, in which case the encoding of your browser will change automatically. Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456132 Share on other sites More sharing options...
jimath Posted February 2, 2008 Author Share Posted February 2, 2008 in the page i looking at. i change the encoding in mozzilla to utf-8-so greek letters are displayed- and when i click a link these letters are not readable. english are displayed ok. Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456136 Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 So you are on page1.php. You click a link on page1.php, and all greek characters on page1.php become unreadable? Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456139 Share on other sites More sharing options...
jimath Posted February 2, 2008 Author Share Posted February 2, 2008 exactly. Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456140 Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 Sorry to get so particular here, but I want to keep confirming. You are saying the text becomes unreadable in between the time you click the link, and the time that the page you are linking to loads? Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456142 Share on other sites More sharing options...
jimath Posted February 2, 2008 Author Share Posted February 2, 2008 yes. but at the beginning too(when i load the index.php page are the letters unreadable) . i change the encoding to utf in mozilla, letters are displayed ok, and when i click a link again unreadable. Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456152 Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 The problem is that the HTTP headers that are being sent to the browser are not UTF-8, but the encoding of the text inside the files is UTF-8. This was kind of what I thought. There are a few possible reasons for this, but I suspect that your php encoding is set to something other than UTF-8. First, when you switch the encoding in the 'view' menu in firefox, you switch it to UTF-8 and it becomes visible right? Second, create a new php file, and add this one line of code to it: <?php echo phpinfo(); ?> Then upload that to the folder that you are having troubles with, and open that file through your browser. Then tell me what it says under HTTP Headers Information => Accept-Charset Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456167 Share on other sites More sharing options...
jimath Posted February 2, 2008 Author Share Posted February 2, 2008 i do not see anything relevant to this (HTTP Headers Information => Accept-Charset) some relevant displayed are: HTTP_ACCEPT_LANGUAGE el HTTP_ACCEPT_ENCODING gzip, deflate _SERVER["HTTP_ACCEPT_ENCODING"] gzip, deflate _ENV["HTTP_ACCEPT_ENCODING"] gzip, deflate Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456179 Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 Can you get access to your php.ini file? You may need to contact your hosting company to find out how to do it. It looks like they may not have the encoding set correctly in it. Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456189 Share on other sites More sharing options...
jimath Posted February 2, 2008 Author Share Posted February 2, 2008 yes i can. i opened php.ini and i saw the following: is anything relevant? ; http input encoding. ;mbstring.http_input = auto ; enable automatic encoding translation accoding to ; mbstring.internal_encoding setting. Input chars are ; converted to internal encoding by setting this to On. ; Note: Do _not_ use automatic encoding translation for ; portable libs/applications. ;mbstring.encoding_translation = Off ; automatic encoding detection order. ; auto means ;mbstring.detect_order = auto ; substitute_character used when character cannot be converted ; one from another ;mbstring.substitute_character = none; Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456199 Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 Not if you are using UTF-8. Those are the the multi-byte string library functions, but UTF-8 is a single-byte language. Look for the part of the php.ini that says default_charset = _____________ it should read: default_charset = "UTF-8" If it doesn't, then post what it does say. Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456204 Share on other sites More sharing options...
jimath Posted February 2, 2008 Author Share Posted February 2, 2008 OK NOW IT WORKS!! THANK YOU VERY MUCH HAKU!!! IT was ;default_charset = "iso-8859-1" and i changed it to: default_charset = "UTF-8" so i have to change the default_charset in php ini correspondingly to what charset i am using to my scripts? or using UTF-8 i am covered? Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456211 Share on other sites More sharing options...
haku Posted February 2, 2008 Share Posted February 2, 2008 If utf-8 is what you want to use (it may or may not be, I don't know what the needs or your website are, or what is recommended for working with Greek languages), then everytime something doesn't come out right, look around for something somewhere that isn't in utf-8. So your documents should be encrypted in utf-8, and you should use utf-8 for the internal encoding. You should set emails with ISO-8859-01 (at least for English) though, and I've heard that utf-8 can be unreliable with emails. I dont know though - I program sites in Japanese so I don't use utf-8, I use multibyte character sets which is a whole different game. Quote Link to comment https://forums.phpfreaks.com/topic/89066-problem-with-charset/#findComment-456215 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.