Of Character Encodings
Date: 11/18/05
(C Sharp) Keywords: database, asp, sql, web
I am converting a web app from ASP to ASP.net and have stumbled on an annoying problem.
1. ASP code accepts user input and stores value in the database
SQL field type is nvarchar(200).
BUT the query does not use N'' to specify that the string is unicode.
2. Value stored in the database is '陳å°æ˜¥'
3. Value displayed on web page (utf8 encoding, no server side changes) is '陳小春'
4. Actual UTF data in the database is displayed on screen as ???
(database value: 人, display value: ?)
5. ASP.net application using the EXACT same queries results in point 4 being displayed correctly (as japanese) but the values that were displayed correctly in the ASP app are now exactly as they are in the database.
Please Help ... My only guess was that the ADO connection was converting the UTF in the database to Non-UTF for display in ASP and the ADO connection in .Net is preserving the Unicodeness of it.
But i did a simple test in ASP where i selected the data, stored it in a variable and then inserted back into the database (non using N'')
and well ... i got the exact same .... japanese was japanese the rest was garbage.
Anyone have any ideas???
Source: http://www.livejournal.com/community/csharp/41546.html