SitePoint Sponsor |
|
User Tag List
Results 1 to 16 of 16
Thread: Korean Text in DB
-
Jan 17, 2006, 05:48 #1
Korean Text in DB
Hi,
I'm currently working on a website which needs to store English and Korean text in a DB field.
The problem is, the Korean typeface is not being stored correctly, it's being totally garbolled.
I believe it has something to do with the DB fields properties, the entry form is a normal text entry field that inserts the data into a mysql DB.
For reference:
This: 회원가입
is being turned into this: ȸ
Does anyone know what is up with this?
-
Jan 17, 2006, 05:53 #2
- Join Date
- May 2004
- Location
- Braga, Portugal
- Posts
- 596
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The problem is in the table's default character set, you should use UTF8 to store korean (or any other multi-byte char language alike)
~ Daniel Macedo
-
Jan 17, 2006, 06:05 #3
Yes, the DB field is UTF8, but it is still garbolled.
I'll elaborate a little.
I have a textarea in a form, where the user can entertext. This text is then stored in a MySQL DB (mediumtext). This can then be displayed on the site (dynamic content).
This fields 'collation' in PHPMyAdmin is set to utf8_unicode_ci (also set it as utf8_general_ci and utf8_bin and it won't work).
I too was under the impression that UTF8 was the character set we needed to use, so this is really confusing me and taking up way too much of my time on this project (as it's an important feature).
-
Jan 17, 2006, 06:21 #4
- Join Date
- May 2004
- Location
- Braga, Portugal
- Posts
- 596
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Have you tried inserting the text in phpMyAdmin? Does that work?
I am sure if you have the right character set and collation it has to work properly.
If that doesn't work the issue can be in your connection to MySQL not using utf8 or something in those lines
I'd have to check the PHP (?) handling of the string and debug that myself to properly understand what's wrong.~ Daniel Macedo
-
Jan 17, 2006, 06:39 #5
Hmm...
OK, entering directly into PHPMyAdmin works, it's stored correctly in the DB however it is displayed on the site as '???? ?? ???' like that.
So something somewhere isn't right, I'm really not sure if its my code (can it be?) or a setup issue with the server?
-
Jan 17, 2006, 06:44 #6
- Join Date
- May 2004
- Location
- Braga, Portugal
- Posts
- 596
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The only thing I can imagine is setting
Code:SET character_set_client = utf8; SET character_set_connection = utf8; SET character_set_results = utf8;
~ Daniel Macedo
-
Jan 17, 2006, 06:56 #7
How do I implement this, add that to the top of the PHP script as is?
-
Jan 17, 2006, 06:58 #8
- Join Date
- May 2004
- Location
- Braga, Portugal
- Posts
- 596
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, try this out.
Right after your mysql_connect() insert:
PHP Code:mysql_query('SET character_set_client = utf8');
mysql_query('SET character_set_connection = utf8');
mysql_query('SET character_set_results = utf8');
~ Daniel Macedo
-
Jan 17, 2006, 07:19 #9
It's made a difference, it's now even more garbolled than it was before, lol.
Register and 회원가입
Instead of ȸ
So it is more messed up than before, I've never had the liberty to work with a company in the far east before, so this is rather new to me.
As a side note, I've tried the following character types in the DB field (and also tried changing the utf8 type in that code sample to reflect).
utf8_unicode_ci
utf8_bin
utf8_general_ci
The rest of the utf8's in phpmyadmin are latin, roman etc. so I don't think they are appropriate.
Leaving the setting in your code sample gives a garbolled output, anything else gives a string of ???? ??? ???
-
Jan 17, 2006, 09:11 #10
- Join Date
- May 2004
- Location
- Braga, Portugal
- Posts
- 596
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think you may be missing something as you're probably using charset ISO-8859-1 on your web page instead of UTF8
Try that and let me know
Edit:
Last edited by DMacedo; Jan 17, 2006 at 13:07.
~ Daniel Macedo
-
Jan 17, 2006, 09:34 #11
No luck there either, this has me totally baffled.
Thanks for all your help though
-
Jan 17, 2006, 09:36 #12
- Join Date
- May 2004
- Location
- Braga, Portugal
- Posts
- 596
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Then only checking it I can see what's wrong.
~ Daniel Macedo
-
Jan 17, 2006, 12:54 #13
- Join Date
- Feb 2004
- Location
- Tampa, FL (US)
- Posts
- 9,854
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
make sure you have the correct character set specified in the header of your HTML document. as a test, you can try changing the character set in the view menu of your browser.
-
Jan 17, 2006, 13:04 #14
Thats a very good point and fixed
Thankyou to both of you
-
Jan 17, 2006, 13:06 #15
- Join Date
- May 2004
- Location
- Braga, Portugal
- Posts
- 596
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by DMacedo
Originally Posted by RGSerge
~ Daniel Macedo
-
Jan 17, 2006, 13:30 #16
No, it didnt work set at UTF8, it did however work as euc-kr
Bookmarks