Re: UTF-8 encoding in AJAX web application.



Hello Allan,

Thanks for your reply.

Of course, for .net application, using the ADO.NET SqlCommand and
SqlParameter objects to supply any dynamic parameters should be the
preferred approach. For your SQL Server 2000 database table's column(that
will store the posted chinese characters), is it defined as unicode
character type(such as nchar, nvarchar or ntext ...)? If the column
datatype is of unicode, it should be able to store the chinese characters
correctly, otherwise, you need to make sure the table/column or database's
collation is correctly set as Chinese collation so that chinese chars can
be stored in non-unicode encoded format.

In addition, for SQL Server (7.0 or 2000) unicode datatype, it is stored in
UCS-2 charset (no matter the data is originally encoded in UTF-8, UTF-16
or....). Here is a good MSDN reference introducing the international
features in SQL Server 2000

http://msdn2.microsoft.com/en-us/library/aa902644(SQL.80).aspx

For your current code that directly use inline SQL command text to execute
the insert query, I think you can try adding a 'N' prefix in each string
parameter, this prefix is used to explicit mark the parameter value as
unicode chars.

#Why do some SQL strings have an 'N' prefix?
http://databases.aspfaq.com/general/why-do-some-sql-strings-have-an-n-prefix
html

If you have any further specific questions, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • Re: sendStringParameterAsUnicode: How to insert unicode data corre
    ... After checking with Microsoft it turns out that transmitting Unicode ... requires a change in the data format sent to the JDBC Receiver channel. ... We have contacted SAP and Microsoft. ... We are using SAP XI and connecting it to SQL Server 2005 using JDBC. ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: UTF-8 encoding in AJAX web application.
    ... For your SQL Server 2000 database table's column(that ... datatype is of unicode, it should be able to store the chinese characters ... In addition, for SQL Server unicode datatype, it is stored ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to store HTML code in SQL server table
    ... but varchar cannot be properly used with unicode ... and has a maximum length of 8000 characters. ... > I support the Professional Association of SQL Server and it's> community of SQL Server professionals. ... >> I'm creating something like a web site builder in ASP.Net, and I need to>> store an HTML code in the SQL server table. ...
    (microsoft.public.sqlserver.server)
  • Re: How to store HTML code in SQL server table
    ... but varchar cannot be properly used with unicode ... and has a maximum length of 8000 characters. ... > I support the Professional Association of SQL Server and it's> community of SQL Server professionals. ... >> I'm creating something like a web site builder in ASP.Net, and I need to>> store an HTML code in the SQL server table. ...
    (microsoft.public.sqlserver.programming)
  • Re: How to store HTML code in SQL server table
    ... but varchar cannot be properly used with unicode ... and has a maximum length of 8000 characters. ... > I support the Professional Association of SQL Server and it's> community of SQL Server professionals. ... >> I'm creating something like a web site builder in ASP.Net, and I need to>> store an HTML code in the SQL server table. ...
    (microsoft.public.dotnet.framework.aspnet)