Solved

MySQL Database Charset

Posted on 2009-04-03
10
509 Views
Last Modified: 2012-05-06
I have a mysql database and the data is stored as UTF-8.  This works fine for the primary site using it (blog), but I'm also make remote calls to the database from ASP website.  When doing this, I get bad characters back from the database.

For example, curly apostrophes and mdashes are stored in mysql as UTF-8 unicode, but when calling the data remotely, I get back garbled characters when doing response.write()

I have changed the response.charset to UTF-8 as well as ISO ... but neither works.

Any ideas?
0
Comment
Question by:golfDoctor
  • 7
  • 3
10 Comments
 
LVL 29

Expert Comment

by:Michael Worsham
ID: 24060176
See if this helps...

Decode and Encode UTF-8
http://www.codetoad.com/asp_utf8.asp
0
 
LVL 16

Author Comment

by:golfDoctor
ID: 24060962
Not sure that's going to handle it.  For example, mdash is stored like this in the mySQL database: â¬
0
 
LVL 29

Expert Comment

by:Michael Worsham
ID: 24061217
I am not an ASP programmer, but your ASP environment is going to have to encode and decode the UTF-8 character set when sending and retrieving from the MySQL database.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Author Comment

by:golfDoctor
ID: 24061788
Maybe this is clearer example.  What I said prior was a bit off.  I can read the database from mySQL fine, and it does response.write OK.  However, I'm taking that data out of mySQL and storing in SQL Server.  The data then is stored in SQL Server, and viewing in SQL Server it shows â¬.
â¬

Open in new window

0
 
LVL 16

Author Comment

by:golfDoctor
ID: 24061793
When posting to EE, the characters don't render as they show in DB either :)
0
 
LVL 16

Author Comment

by:golfDoctor
ID: 24061816
This is the HTMLEncode that results from the mdash in mySQL.  â€”
0
 
LVL 29

Assisted Solution

by:Michael Worsham
Michael Worsham earned 100 total points
ID: 24061886
0
 
LVL 16

Author Comment

by:golfDoctor
ID: 24061923
Yes, I saw SET NAMES before, but didn't want to screw up the DB.  Maybe I'll give it a shot.
0
 
LVL 16

Author Comment

by:golfDoctor
ID: 24062101
I don't feel like messing with SET NAME and possibly screwing up the database.  

I fixed my issue though.  The problem was moving data directly from mySQL to SQL Server.   I made an intermediate page to response.write all the necessary data to the page, which does display the correct data, and then scraped that with XMLHTTP to add it to the SQL Server database.

A bit crude, but it works.
0
 
LVL 16

Accepted Solution

by:
golfDoctor earned 0 total points
ID: 24115677
No solutions, other than my intermediate page.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySql Recovery 2 35
window close link 7 35
2012 SQL to JSON Select 5 31
Validating number not work with decimal 4 29
Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question