Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Japanese characters display incorrectly (ASP, MySQL5)

Status
Not open for further replies.

Spork52

Programmer
Nov 20, 2007
134
US
I've got an ASP page that retrieves and displays text from a MySQL5 DB. The text is in English and Japanese. Works fine on the production server. On the development server the Japanese displays as gibberish (E.g., €šã‚‚ç´?å¾—ã?®å“?ã?žã‚?ã?ˆã?¨ï¼“æ‹?å ?ã??ã‚?ã).

The page uses the same connection string on each server to connect to the same database:

Code:
connectstring = "Driver={MySQL ODBC 3.51 Driver}; Server=xx.xx.xx.xx; Port=3306; Database=mydatabase; USER=myuser; PASSWORD=mypassword;"

When I added charset=UTF8; to the connection string I still got gibberish, but more of it.

The page has UTF-8 character set specified in the head:
Code:
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
And, if it makes any difference, the doctype is:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
The database is populated by using PHP pages (forms) with a connection string that does not specify the character set. Could that be part of the problem? If so, then why does the page on the production server work okay? Also, the PHP pages display correctly. Querying the database with SHOW VARIABLES LIKE 'character_set_database'; indicates that the DB is using UTF-8.

What else could make the Japanese display incorrectly? Are there ASP server settings that could make a difference?
 
Thanks, but the char set needs to be UTF-8. And, I looked at the site today and, after weeks of displaying incorrectly, it is now magically okay, even though I didn't change anything. Hmm.
 
Sounds like a cache problem. Probably clearing the cache would have also cleared the issue.
:p

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Meta tags are for the html file. The charset of the output is whatever the browser can display. Do you want your HTML source to be UTF-8 or do you need to send UTF-8 to the browser?
 
Today the Japanese went back to gibberish. I cleared and disabled the cache and re-opened the browser. The Japanese went back to looking okay, but a few minutes later it was gibberish again!

This is all taking place in OS X with Safari. I tried it in IE 6, 7, 8 and OS X FireFox, but, so far, couldn't replicate the problem.

Perhaps it's a problem peculiar to Safari, although it is odd that on the production server the japanese has always displayed properly.
 
Save the page when it displays correctly and save it when it shows gibberish and compare the two. May give you a clue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top