Asp.net renders string with wrong encoding, but PHP doesn't (MySQL)

Posted by citronas on Stack Overflow See other posts from Stack Overflow or by citronas
Published on 2010-05-20T16:55:23Z Indexed on 2010/05/20 17:10 UTC
Read the original article Hit count: 266

Filed under:
|
|
|
|

I took over some old php application with MySQL as database. Inside the database, there are tables including content with localized strings (therefore containing special chars)

Currently there is a PHP application accessing that database. My job is to create an ASP.net (C# codebehind) application that accesses that strings as well. That works, as far as encoding goes.

If I try to access these strings, I do get a kind of encoding problem, like 'Ändern' and 'Prüfzeichen', but only in the ASP.net application. The PHP app sets utf-8 as charset and the strings are perfectly rendered. In the ASP.net application it's gibberish, regardless of the page encoding.

In the MySQL database, the charset for the specified table 'translations' is set to 'latin --cp1252 West European' and collation to 'latin_swedish_ci'.

I can't seem to figure out what PHP apparently does, and ASP.net does not. I traced the php code and could not find any sign of special encoding while getting a string from the database.

The question is, how can I ensure correct encoding inside the ASP.net application without modifying the database, because big changes at the php code are not possible?

Does anybody have a clue?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#