Last post Sep 20, 2011 07:54 PM by rstrahl
Sep 16, 2011 10:31 AM|Mogili|LINK
We had classis ASP application (which caters services to global users) and we set encoding to Windows-1252, and its been there for long time. And few years back we migrated to ASP.Net but left the encoding to windows-1252 ( to support existing data)
Recent days we have encountered problems with Japaneese and Chinese users, so decided to change encoding to UTF-8,
So what is best approach to minimize the issues for existing data ( which was stored in windows-1252 ).
Sep 20, 2011 06:15 AM|wangping827123|LINK
Sep 20, 2011 07:54 PM|rstrahl|LINK
Not sure, what you mean by best approach. If you switch your data to UTF-8, clients that receive the data and expect Windows-1252 will break unless they are automatically sniffing the encoding properly.
Changing the encoding is easy enough to do in web.config with:
One thing you can do is allow for a flag (querystring flag or request header) on the request to specify which encoding should be returned. Then in your actual code that generates output you can set Response.Encoding as needed in code.
var q = Request.QueryString["enc"];
if (!string.IsNullOrEmpty(q) && q == "utf8")
Response.ContentType = "text/html;charset=Utf-8";
Response.ContentEncoding = Encoding.UTF8;
Response.ContentType = "text/html;charset=Windows-1252";
Response.ContentEncoding = Encoding.GetEncoding(1252);
This way you can serve responses both ways overriding whatever global settings are made to ASP.NET.
+++ Rick ---