Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > UTF-8, UTF-16 - ASP VB MSSQL Server - It just doesn't work.

Reply
Thread Tools

UTF-8, UTF-16 - ASP VB MSSQL Server - It just doesn't work.

 
 
InvestorTrade
Guest
Posts: n/a
 
      02-26-2008
When I POST using UTF-16 on the web using ASP and VBScriipt
(not .Net), to a MSSQL Server 2000, my data gets stored in weird
characters. My application is used worldwide (Chinese, Japanese,
German, Spanish...) all sharing the same database, but each location
stores their information using their own language. When I retrieve
the data on the Web, the characters look fine - but using SQL Query
Analyzer the characters are all mangled.

I also have an offline application (written in HTA, VBScript, and
Javascript) that allows my users to upload their data at a later
point
via a CSV file created using UNICODE, which appears to store the data
properly under the MSSQL Server (I confirm this by using Query
Analyzer)


To make things worse, the Web application will display properly the
data that it stored with the POST, but the data that was uploaded
though the CSV file displays incorrectly ( '???' characters). The
effect appears to be reversed when I use MSSQL Query Analyzer to
inspect the data - all the data that was uploaded using the CSV file
appears correct, but all the POST data is mangled.


I've placed under all the Web Pages forms and POST action pages:


<meta http-equiv="Content-Type" content="text/html; charset=utf-16">


I've also made all my forms to have:
<form accept-charset='utf-16'... >


I'm using Chinese in conjunction with English to troubleshoot my
problem.


 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      02-26-2008
"InvestorTrade" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> When I POST using UTF-16 on the web using ASP and VBScriipt
> (not .Net), to a MSSQL Server 2000, my data gets stored in weird
> characters. My application is used worldwide (Chinese, Japanese,
> German, Spanish...) all sharing the same database, but each location
> stores their information using their own language. When I retrieve
> the data on the Web, the characters look fine - but using SQL Query
> Analyzer the characters are all mangled.
>
> I also have an offline application (written in HTA, VBScript, and
> Javascript) that allows my users to upload their data at a later
> point
> via a CSV file created using UNICODE, which appears to store the data
> properly under the MSSQL Server (I confirm this by using Query
> Analyzer)
>
>
> To make things worse, the Web application will display properly the
> data that it stored with the POST, but the data that was uploaded
> though the CSV file displays incorrectly ( '???' characters). The
> effect appears to be reversed when I use MSSQL Query Analyzer to
> inspect the data - all the data that was uploaded using the CSV file
> appears correct, but all the POST data is mangled.
>
>
> I've placed under all the Web Pages forms and POST action pages:
>
>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-16">
>
>
> I've also made all my forms to have:
> <form accept-charset='utf-16'... >
>
>
> I'm using Chinese in conjunction with English to troubleshoot my
> problem.
>


Try adding this to the top of the ASP page receiving the Form post:-

<%@codepage=1200%>

The codepage is what the ASP uses to determine how a characters in the post
are encoded.
The assumption is that this is the same codepage as it would use to generate
its output.

When the correctly received CSV data when sent from ASP would have been
encoded as the current system codepage (probably 1252 or something like
that). But your meta Content-Type header says its unicode hence it appears
corrupted.

OTH, when you sent the already corrupted SQL data to the client the reverse
of the corruption occurs and hence to the client it looks ok (its
complicated).


My general advice on this is. Save all pages as UTF-8.

Include this in the top all pages:-

<%@codepage=65001 %>
<%
Response.CharSet = "UTF-8"
%>


In this way all static is content is UTF-8, all dynamically generated
content is encode to UTF-8, all form posts are assumed to be UTF-8 and the
browser is informed that its getting UTF-8.

BTW, don't bother with the meta Content-Type tag. Its purposes is to
pretent to be the Content-Type header when a HTM file is opened from a file
system. Since ASP is sending a real HTTP response you may as well set those
headers for real. text/html is the default content-type and the
Response.CharSet adds the ;charset=UTF-8 to it.

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
 
 
 
InvestorTrade
Guest
Posts: n/a
 
      03-03-2008
Thanks a lot! this worked like a charm!

For anyone else having problems out there - follow the post from:
Anthony Jones.

Thanks mate.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MSSQL Server in ASP.NET KA Kueh ASP .Net 1 01-31-2007 07:50 AM
MSSQL Server Boris Sherman Computer Support 1 11-07-2005 04:21 AM
using forms or windows authentication for Login in MSSql Server(integratedsecurity) sefe dery ASP .Net 1 09-07-2005 08:30 PM
ASP Net starter pack - MSSQL Server problems so can't finsih tutorials. Dave Smithz ASP .Net 0 07-09-2004 02:01 PM
MSSQL server error? How to fix Hai Nguyen ASP .Net 0 03-04-2004 09:45 PM



Advertisments