The String type deals with utf16 strings only. Of course you can use an utf8
encoding when reading/writing from/to an external destination (such as a
file or a web browser response stream).
Not sure why you want to keep the string using utf8 but I'm afraid that
depending on what you'll do with the string it could well introduce some
subtil problems (I would keep it a s abyte array in the worst case if
possible)...
You may want to elaborate about what you are trying to do and in particular
what you'll do with this string once encoded using utf8 (for example even
with creating mails the idea is that .NET always uses utf16 but you can ask
to encode as utf8 when you write youtr content to the mail object, a file, a
browser stream, a database etc...)
--
Patrice
"Samuel" <sa************ @ntlworld.coma écrit dans le message de groupe de
discussion : Oa************* *@TK2MSFTNGP03. phx.gbl...
>
Hi
I am trying to write to a string text encoded to utf8 as oppose to utf16
Since the data comes from an XML object (and I serialize it) I need to
pass either StreamWriter or a StringWriter object, I don't want to create
a file so I want to use a StringWriter (passing to it's constructor a
StringBuilder) The problem is that the StringWriter encodes utf16 (I don't
know how to change it)
Any Advice?
Thank you in advance,
Samuel