Re: UTF-8 encoding in AJAX web application.
- From: "Allan Ebdrup" <ebdrup@xxxxxxxxxxxxxxx>
- Date: Wed, 21 Mar 2007 12:59:23 +0100
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:1174475482.881336.295840@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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".
I don't get why you can't say a System.String is UTF-8 encoded? if the bytes
in the string have to be read with a UTF-8 encoding to make sense? Granted
you would like the string to be UTF-16, but the bytes in the string have to
be read with a UTF-8 encoding to get the right meaning.
Where does my UTF-8 encoded XML get translated to UTF-16, I've got the
contents in a CDATA section and I fetch it using:
---
string text = xmlDocument.SelectSingleNode("QuestionText/text()").Value
---
So does fetching the CDATA section's value like this actually translate from
UTF-8 encoding to UTF-16 because all strings in .Net are UTF-16? (I thought
it just byte-copied the contents of the CDATA section, therefore I would get
a UTF-8 encoded string in the "text" variable).
And because the string is translated to UTF-16 it gets stored correctly in
the database when I pass it as a parmeter to the database?
OR
The string that is the XML gets passed to my webservice as a parameter that
I load into an XML document. As mentioned earlier I set my website to use
UTF-8 when sending/recieving data, is the string actually transformed from
UTF-8 to UTF-16 (because all strings are UTF-16 in .Net), before it is
passed to my webmethod?
I'mean I have a UTF-8 encoded string when I send it on the wire, and
somewhere it gets translated to a UTF-16 string that is stored in the
database as UCS-2 (UTF-16 to UCS-2 and back is handled by the driver as I
understand it)
The bytes of my original UTF-8 string are not the same as the bytes stored
in the UCS-2 string in the database so they have to get translated
somewhere, I'm just trying to understand where this translation occurs.
I know I could just drop it because it works, but I too curious about what
actually happens.
Kind Regards,
Allan Ebdrup.
.
- Follow-Ups:
- Re: UTF-8 encoding in AJAX web application.
- From: Jon Skeet [C# MVP]
- 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
- Re: UTF-8 encoding in AJAX web application.
- From: Jon Skeet [C# MVP]
- UTF-8 encoding in AJAX web application.
- Prev by Date: Re: Simple web fetching class with: string Get(string URL), bool Busy and Stop() members
- Next by Date: Re: IPropertyChanged implementation, best practice
- 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
|