473,322 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

utf8

Hi,

I'm running php5 and mysql5, both configured for utf8... When I save
data into a table, and look at the table with e.g. phpmyadmin, the
data
has weird characters like: è and é in it.Actually this isn't a
big problem: when I print the data in my browser, the accents look
fine.

I read that when you execute a query "SET NAMES utf8", the weird chars
would disappear in the db, ...and still everything works fine.

So I tried to decode the utf8 data in my tables with using
utf8_decode... But it seems like it doesn't decode everything.

For example this doesn't work :echo utf8_decode('Problème à la
sauvegarde des données.');

You will notice the à isn't converted into an à.

So I have 2 questions :

- should i use the SET NAMES query, or is it normal when you have
those
characters in your table
- how can I convert the à into an à

Thanks in advance!

Feb 22 '07 #1
2 3881
I'm running php5 and mysql5, both configured for utf8... When I save
data into a table, and look at the table with e.g. phpmyadmin, the
data
has weird characters like: è and é in it.Actually this isn't a
big problem: when I print the data in my browser, the accents look
fine.
<snip>

I have burned my fingers a lot with encodings, lately. The problem is
that texts do have encodings, while strings do not. And off course, that
texts are stored as strings.

what you are seeing is utf-8, but shown as if it was latin-1 (or a
derivative). The reverse shows question marks, as most special
characters in latin-1 are not well formed utf-8.

I installed phpMyAdmin as well, because the site and the browser are now
working together just fine (IE and Firefox, at least), So any text gets
entered in utf-8 in the database and rendered the same as it was
entered. My hope was that phpMyAdmin would enable me to enter strings
directly into the database, as it is running inside a browser also. Bad
luck. Both phpMyAdmin and my regular database frontend show utf-8 as if
it is latin-1.

There is a lot that can go wrong:
- Your OS has an encoding
- The frontend program may have an encoding
- The database connection has an encoding
- The field has an encoding

There may be conversions at any point, but mostly texts are not
converted and I do not understand why you can give an encoding if it is
never used anyway.

Alas, there is no "unicode escape" either in MySQL (like "/Uxxxx" in
some languages). So it is impossible to store a query in a file, upload
it to another OS and have the encoding automagically set right. Some
encoding solutions are really laughable. Do you think that "SET NAMES
utf16le" will ever be executed? Only if it is a lie and NOT issued in
such an illegible encoding.

I am sorry that this is not very helpful, but I think I just need a
shoulder to cry on.

Wèèèèèèèèèèè !

--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Feb 23 '07 #2
ge***********@gmail.com wrote:
Hi,

I'm running php5 and mysql5, both configured for utf8... When I save
data into a table, and look at the table with e.g. phpmyadmin, the
data
has weird characters like: è and é in it.Actually this isn't a
big problem: when I print the data in my browser, the accents look
fine.

I read that when you execute a query "SET NAMES utf8", the weird chars
would disappear in the db, ...and still everything works fine.

So I tried to decode the utf8 data in my tables with using
utf8_decode... But it seems like it doesn't decode everything.

For example this doesn't work :echo utf8_decode('Problème à la
sauvegarde des données.');

You will notice the à isn't converted into an à.

So I have 2 questions :

- should i use the SET NAMES query, or is it normal when you have
those
characters in your table
- how can I convert the à into an à

Thanks in advance!
You might want to have a look here for some more information:
http://adviesenzo.nl/examples/php_mysql_charset_fix/
Feb 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: sinasalek | last post by:
i have a problem with MySQL 4.1.x and UTF8. in version 4.0, i'm using html forms with utf8 charset for inserting unicode strings. but in version 4.1.x it is not working! if i change the charset of...
5
by: Richard Lewis | last post by:
Hi there, I'm having a problem with unicode files and ftplib (using Python 2.3.5). I've got this code: xml_source = codecs.open("foo.xml", 'w+b', "utf8") #xml_source = file("foo.xml",...
6
by: Spamtrap | last post by:
I only work in Perl occasionaly, and have been searching for a solution for a conversion, and everything I found seems much too complex. All I need to do is take a simple text file and copy...
1
by: ryang | last post by:
I am trying to understand how to work with Unicode in Perl. I have read the relevant man pages (perluniintro, perlunicode, etc.) and have written severl scripts to test/verifiy my understanding. ...
0
by: Sagi Bashari | last post by:
Hello, I would like to know the status of the UTF8 support in MySQL 4.1. I tried to create a table using utf8 charset, and inserting hebrew text into it. it seems like it still treats this...
0
by: JJ | last post by:
Hi, I have a little, big, boring problem :) I have a utf8 txt file to import in a MySQL db, cause I must create a web-application in PHP for reading this information on-line. I have create...
3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
4
by: H Lee | last post by:
Hi, I'm an XML newbie, and not sure if this is the appropriate newsgroup to post my question, so feel free to suggest other newgroups where I should post this message if this is the case. I'm...
7
by: amygdala | last post by:
Hi, I'm trying to let PHP write a 'sitemap.xml' sitemap for Google and other searchengines. It's working, except that the content in the XML file doesn't seem to be UTF8. (Which it should be,...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.