| Subject: Re: convert utf8 problem |
| Date: 30.10.2005 07:57:05 |
dongxm <iamdbb@domainhidden> wrote:
[Original Message clipped] Do you mean you want a string with the unicode escapes in? Note that
that isn't UTF-8, particuarly.
Note that "a" is \u0061 by the way - escape values are in hex, not
decimal.
This prints out the escaped version of the first command line parameter
you give it:
using System;
using System.Text;
public class foo
{
static void Main(string[] args)
{
StringBuilder builder = new StringBuilder(args[0].Length*6);
foreach (char c in args[0])
{
builder.Append("\\u");
builder.AppendFormat("{0:X4}", (int)c);
}
Console.WriteLine (builder.ToString());
}
}
See http://www.pobox.com/~skeet/csharp/unicode.html for more about
encodings, and http://www.pobox.com/~skeet/csharp/strings.html for more
about strings in general.
--
Jon Skeet - <skeet@domainhidden>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
|