Link to home
Start Free TrialLog in
Avatar of pravetz
pravetz

asked on

IIS and MySQL Cyrillic Problem

Running:
Win 2003 Server - regional settings English(US)
MySQL Default CharSet: cp1251

Using ASP to pull out and insert records in the DB. Im trying to work with Cyrillic but no luck. Seems like nothing is working for me. I tried:
<%@ CodePage=1251 %>
And I'm keeping this meta-tag at all times:
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
but still the records are added and read wrong. I either get "?????????" or bunch ot messed up chars for my record.

Now if I change the server's regional settings it would work fine!
However I don't feel this is the right decision (What if that was a public web server hosting hundreds of sites with different languages!). I googled for hours on this and still nothing.
Please help!
What is the general practice for working with Cyrillic content under IIS/MySQL.

Avatar of VoteyDisciple
VoteyDisciple

The first thought that comes to mind is to run, as a SQL query,  'SET NAMES cp1251' after connecting (indicating that you wish to communicate with MySQL in cp1251 -- a decision that's entirely independent of how data are actually stored in your tables).
Avatar of pravetz

ASKER

Ok after trying all kinds of combinations here's where I got to:

<%@ CodePage=1251 %>
Response.CodePage = 0
Response.CharSet = "cp1251"

And "Stmt=SET NAMES 'cp1251'" in the MySQL query

Records are adding correctly and Reading correctly. However when I try to use Server.HTMLEncode() on them I get garbage like - ôñäôäñô

Any idea?
So if you output data directly to the page (i.e. without calling Server.HTMLEncode()) it shows up correctly, but once you do Server.HTMLEncode() it gets screwed up?  Do only special characters get screwed up (i.e. a single é becomes ôñäôäñô or something) or do all characters suddenly go nuts?
Avatar of pravetz

ASKER

Yes If I output the text without calling Server.HTMLEncode() text displays OK. Once I use Server.HTMLEncode() ALL of my chars get screwed, text becomes totally unreadable.
My best guess is that Sever.HTMLEncode() doesn't know what encoding your original data were, but I don't know how you might correct that.  Setting Response.CharSet seems like it ought to do it, but I haven't worked with character encodings in ASP before so I don't actually know.
Avatar of pravetz

ASKER

Googled on Sever.HTMLEncode() a lot but nobody seems to have my problem. I think the key is in the fact that if I switch "Regional Settings" of the server to my language all works fine. I hope that's not my only option.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial