Use of Accented Characters

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
BetoBoton
Forum Newbie
Posts: 3
Joined: Wed Feb 17, 2010 4:49 am
Location: São Paulo - Brazil

Use of Accented Characters

Post by BetoBoton »

What is the correct settings to get Accented Characters stored and retrieved properly via PHP on a MySQL Database?

I need to get accented characters properly stored and retrieved via PHP on a MySQL Database.
The language is Brazilian Portuguese, but if I use French, for example, the great majority of this set is also present and the problem to set it up properly remains.
The PHP and MySQL Documentation is not of great help in this matter.


Here are the Accented Characters

ç Ç

á é í ó ú ü Á É Í Ó Ú Ü

à è ì ò ù À È Ì Ò Ù

ñ ã õ Ñ Ã Õ

â ê î ô û Â Ê Ô Û

Here is what I end up with in MySQL DB via PHP form

ç Ç

á é í ó ú Á É Í Ó Ú

à è ì ò ù À È Ì Ò Ù

ñ ã õ Ñ Ã Õ ü Ü

â ê î ô û Â Ê Ô Û não

Here is what more:

Users write a message using accented characters and it does not differ if using a Mac or a PC, if the characters are typed via localized keyboard or using a standard QWERTY and Alt Key to generate these caracters.

Here is the result using something provided in a software called Sequel Pro that encodes using (UTF8 via Latin1) The result is perfect!

Sei que p que se faça uma previsão é preciso q se tenha feito uma retificação de hora, n tenho este curso, e a retificação q fizeram, sinto n ser exata, qual o preço da previsão pelo skype? eu sou grata!
Ordália

Here is the result as Encoding UTF8 (the result is all scrambled as it is if seen by PHPMyAdmin

Sei que p que se faça uma previsão é preciso q se tenha feito uma retificação de hora, n tenho este curso, e a retificação q fizeram, sinto n ser exata, qual o preço da previsão pelo skype? eu sou grata!
Ordália

======================
There seem to be a "correct combination" between the PHP CODE settings, and the server MySQL seetings in order to store and retrieve these characters properlu.

It seems (reading vague posts elsewhere) the correct settings for PHP would be to set a locale "pt_BR.utf-8" or "pt_BR.iso-8859-1", is it true?

This is incredible, I tried a lot of changes on the MySQL side (leaving PHP as UTF8 and AS Latin1 with no success:
Well. I tried changing MySQL collation to
utf8_bin
latin1_bin
latin1_general_ci
latin1_general_cs
and then to
latin1_swedish_ci (why not???)
It did not result in storing accented characters properly.


Any help on this matter would be more than welcomed since I'm lost.

Beto Boton
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Use of Accented Characters

Post by requinix »

* ISO 8859-1 is weak. Use pt_BR.utf-8.
* Last I knew, phpMyAdmin had problems displaying UTF-8 content. Don't worry about it.
* Make sure your pages are displaying correctly.

Code: Select all

header("Content-Type: text/html; charset=utf-8");

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
One (or both) of those should be enough.
BetoBoton
Forum Newbie
Posts: 3
Joined: Wed Feb 17, 2010 4:49 am
Location: São Paulo - Brazil

Re: Use of Accented Characters

Post by BetoBoton »

Thank you very much for your answer.
I believe it help me a bit.

I need to import what is in MySQL DB on the hosting server, into my local FileMaker Pro 9 (local machine iMac OS X 10.5.8)
I can do that via ODBC with no problem, as long as the PHP questionnaire, that my client will fill it in on the web, is capable of storing the proper characters on MySQL field ( this is not happening I get gibberish instead of accented characters).

Is it something on:
1- PHP form that needs to be set
2- MySQL DB collation that needs to be set
3- All the above
4- None of this

From what I did try, assigning UTF8 (PHP form and MySQL Collation) was not enough to assure I'll be able to retrieve the accented characters.

Thank you very much for more suggestions

:banghead: Beto
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Use of Accented Characters

Post by Eran »

BetoBoton
Forum Newbie
Posts: 3
Joined: Wed Feb 17, 2010 4:49 am
Location: São Paulo - Brazil

Re: Use of Accented Characters

Post by BetoBoton »

Thank you so much
I'll read it carefully

Sorry if I ask such beginners questions but I'm quite a few days trying to get this working with no avail....

Regards
Beto :banghead:
Post Reply