Dog
Dog

Reputation: 663

hebrew encoding from MYSQL in ASP delivers?

i've built a site for a client using classic ASP with MySQL database as the back-end. everything works fine on the test server, but when i transferred the site to the live server all the hebrew data pulled from the database was coming out in gibberish...

the database is set as UTF-8. i've checked the database content with phpmyadmin and the hebre is readable.

it looks like the problem is the ODBC drivers. on my server i'm using ODBC 5.1 while on the live server they are still using 3.51... apparently hebrew was a problem with this odbc driver, but the host company refuses to update, even though its an israeli hosting company....

my database connection string looks like this :

"DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=100298270_dbname; UID=username;PASSWORD=pass; OPTION=0;charset=utf8;"

so, after many hours reading i've found the following solutions, none of which have helped:

  1. running this query on the database before other queries :

    SET NAMES utf8"

  2. running all of these queries :

    Call SqlQuery("SET character_set_client=utf8") Call SqlQuery("SET character_set_connection=utf8") Call SqlQuery("SET character_set_database=utf8") Call SqlQuery("SET character_set_results=utf8") Call SqlQuery("SET character_set_server=utf8") Call SqlQuery("SET NAMES utf8")

but nothing seems to change when i've run them 'ive tried to implement this solution MySQL ODBC 3.51 Driver UTF-8 encoding but as i only have access to a PLESK control panel for the hosting i can only create a default DSN connection.

i spoke to tech support at the hosting company and they said that other ASP sites were working correctly (even though its a known issue that 3.5 ODBC driver doesn't support unicode) and so i would have to find the solution myself... i was told to connect to the MySQL database with a "DSN-less connection...

anyone have a solution for me?

Upvotes: 1

Views: 1292

Answers (1)

ThatGuyInIT
ThatGuyInIT

Reputation: 2239

You also have to change the CodePage as ASP will use ANSI code page by default.

http://msdn.microsoft.com/en-us/library/ms524628(v=vs.90).aspx

You also need to make sure your Charset is set to UTF-8

Response.Codepage = 65001  'Forces ASP to use UTF-8 for string encoding
Response.Charset = "UTF-8" 'Sets charset variable of content type response header
Response.LCID = 1037 'Hebrew Locale ID

You may also need to add a HTML meta tag to force browsers to use UTF-8.

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

Also try appending this to the beginning of each query:

SET NAMES HEBREW

Upvotes: 1

Related Questions