Portuguese charset problem

2020-02-06 04:44发布

问题:

I’m a headache with the damn charset.

Portuguese charset=iso-8859-1

On my HTML I have:

<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" /> 

On my config.php:

$config['charset'] = 'ISO-8859-1'; 

I have the word ‘café’, coffee.

It is been displayed like: cafŽ.

Any ideas?!

Thanks in advance for any help

**Edit

I don't know if it matters but I'm using Eclipse

回答1:

What's the encoding of the file in Eclipse set to? Right-Klick on the file in Eclipse, check under "Properties". It must be the same as in your meta-tag.



回答2:

thanks so much, i believe your answer is the best one:

$string = 'café'; 
utf8_decode($string); 

OR

$string = 'café'; 
utf8_encode($string);

with meta charset in the header of each file, the issue of portugues characters will be solved.



回答3:

Why don't you switch to UTF-8?

edit You might also want to switch to using entities.

&eacute; would be the é

http://www.w3schools.com/tags/ref_entities.asp



回答4:

I would look at the default charset in the browser first, it could be set to ISO-8859-15 or UTF8. I have had the reverse problem of my browser encoding was set to ISO-8859-1 instead of UTF8.

Secondly is this data static or coming from a database? If it is from mySQL for example, check the collation of the database, is it in latin1 or utf8? If coming from a UTF8 collated database (or not - as you're using PHP) you can try

$string = 'café';
utf8_decode($string);

OR

$string = 'café';
utf8_encode($string);

Moving to UTF8 may be a good idea because functions like PHPs utf8_encode() and utf8_decode() but if it's not appropriate to your market then that is that.

If the utf8_encode or utf8_decode functions work, you should look at your input method and input encoding as you will likely find a problem there.

P.S. I have the same problems from time to time being in Brazil... I feel your pain mate!



回答5:

Try this one here:

$string = 'café';
htmlentities($string, ENT_COMPAT, 'utf-8');

Take care!



回答6:

Go to the resource bundle in the project explorer and then right click on that file and change char set to utf=8 and then save the settings.