Welcome to WebmasterWorld Guest from 54.146.59.202

Forum Moderators: bill

Message Too Old, No Replies

php GB2312 UTF-8 issue

php GB2312 UTF-8 issue

     
1:17 pm on Oct 10, 2007 (gmt 0)

5+ Year Member



Hi - I have a Chinese site that had its charset as UTF-8. we are storing text as UTF-8 in MySQL5 db. Quite a few of my users in China that have GB2312 encoding set in their IE browsers can't see the site. We changed the charset in ph to be GB2312 but some characters are coming out odd like as? (question marks).

We would like to store as UTF-8 and display as GB2312 - but without the funny chars.

Please help!

12:34 am on Oct 11, 2007 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Those are 2 completely different character set encodings. To the best of my knowledge you need to choose one or the other. Simply changing the charset will cause more problems than it will solve.

If you use a proper DTD, language and charset declaration meta tags your users should have no difficulty seeing UTF-8 pages at all. What do your headers look like? Could you post a snippet?

9:36 am on Oct 11, 2007 (gmt 0)

5+ Year Member



Hi Header is <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

we have also tried using meta language zh

the site is ok in Firefox but can't be seen in IE

12:19 am on Oct 12, 2007 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



That's fine for declaring UTF-8 as the charset, but what DTD are you using? How are you declaring the language?

Here's how I do one of my Chinese sites:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh" />

Note the language declaration in the HTML tag. That helps the most.

9:26 am on Oct 12, 2007 (gmt 0)

5+ Year Member



Hi - but are Chinese users that only have gb2312 browser encoding able to see the site properly?

Do you have a url for your site so I can see if my users who can't see mine properly can see that?

Thanks for help

12:30 pm on Oct 12, 2007 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Hi - but are Chinese users that only have gb2312 browser encoding able to see the site properly?

The site's been tested with IE5, IE6, IE7, Opera, Firefox, and Safari. I've tested it with Traditional and Simplified Chinese operating systems (Windows & Mac) as well as Japanese and English. The site has never failed to show up in that range of software and operating systems.

URL

Sorry, we're not alowed to post URLs to our own sites or example sites at WebmasterWorld.
12:40 pm on Oct 12, 2007 (gmt 0)

5+ Year Member



cheers Bill - can you send me URL in private message?

We are really stuck on this and its casuing quite serious downtime.

11:33 pm on Oct 12, 2007 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Let's keep the conversation in the forums. Why not post a snippet of code from your site as I suggested in my first message? I even posted an example of the code I was looking for from your site.

This isn't a question of looking at example sites, but rather standard code and possibly your server setup. As you say in your first post, your data is in UTF-8 already. You're probably using PHP too, correct? Do you have mbstring setup properly?

Again, a snippet from your code might help our understanding of your issue. Another thing you might want to try is to check whether your HTML is valid with a validator [validator.w3.org].

 

Featured Threads

Hot Threads This Week

Hot Threads This Month