Re: UTF-8 encoding in AJAX web application.
- From: "Jon Skeet [C# MVP]" <skeet@xxxxxxxxx>
- Date: 21 Mar 2007 04:11:22 -0700
On Mar 21, 8:40 am, "Allan Ebdrup" <ebd...@xxxxxxxxxxxxxxx> wrote:
No - the driver will do that for you.
Is this done by detecting the UFT8 preamble? And the the driver converts to
UCS-2? And if so how come the result is still in UTF-8 when I retrieve the
data again?
It's done by passing in strings as the parameters. At that stage
there's no encoding involved (well, sort of - all .NET strings are
actually UTF-16, which is very similar to UCS-2, but you can
effectively ignore that). In particular, it is meaningless to say that
a string (as a System.String) is "UTF-8 encoded".
Why is it important that MSSQL only supports UCS-2 unicode if everything
works fine with UTF-8?
That's the internal storage format, that's all. (It may mean you can't
support characters not in the Basic Multilingual Plane, but it's not
worth worrying about that at this stage.)
I can see that everything works fine when storing a UTF-8 string in an ntext
column, and when I query the data in queryanalyzer the string is displayed
correctly in the result set, how can this be if MSSQL only supports UCS-2
encoding?
How is the string stored? in UTF-8 or UCS-2?
UCS-2 in the database. When you fetch it from the database, the driver
will convert it into a .NET string for you.
The main point is that so long as you use parameters/queries which
just use strings, you shouldn't need to worry about it at all in your
code: so long as you start with the right string (wherever it came
from) it should be stored correctly.
Sorry for all the questions, I'm just tryng to understand what's going on.
Have you read http://pobox.com/~skeet/csharp/unicode.html ? It may
help.
Jon
.
- Follow-Ups:
- Re: UTF-8 encoding in AJAX web application.
- From: Allan Ebdrup
- Re: UTF-8 encoding in AJAX web application.
- References:
- UTF-8 encoding in AJAX web application.
- From: Allan Ebdrup
- Re: UTF-8 encoding in AJAX web application.
- From: Jon Skeet [C# MVP]
- Re: UTF-8 encoding in AJAX web application.
- From: Steven Cheng[MSFT]
- Re: UTF-8 encoding in AJAX web application.
- From: Allan Ebdrup
- Re: UTF-8 encoding in AJAX web application.
- From: Steven Cheng[MSFT]
- Re: UTF-8 encoding in AJAX web application.
- From: Allan Ebdrup
- Re: UTF-8 encoding in AJAX web application.
- From: Allan Ebdrup
- Re: UTF-8 encoding in AJAX web application.
- From: Allan Ebdrup
- Re: UTF-8 encoding in AJAX web application.
- From: Jon Skeet [C# MVP]
- Re: UTF-8 encoding in AJAX web application.
- From: Allan Ebdrup
- UTF-8 encoding in AJAX web application.
- Prev by Date: string copying
- Next by Date: Re: ThreadStart parameters
- Previous by thread: Re: UTF-8 encoding in AJAX web application.
- Next by thread: Re: UTF-8 encoding in AJAX web application.
- Index(es):
Relevant Pages
|