差异/你和&# [英] difference /u and &#

查看:64
本文介绍了差异/你和&#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我从数据库收到一个utf8字符,例如&#30000(日语

字符,样式:& #XXXXX) 。

如何在我的应用程序中可视化日文字符?我在类System.Text.Encoding中找到了

,但输入看起来像是\ uXXXX。我不知道b $ b知道该怎么做。


谢谢你,


巴特

Hi,

I receive an utf8 character from a database, like &#30000 (Japanese
Character, style: &#XXXXX).
How can I visualize the Japanese character on my application? I have found
the class System.Text.Encoding, but the input looks like \uXXXX. I don''t
know how to do.

Thank you,

Bart

推荐答案

Bart< ba ** @ bart.it>写道:
Bart <ba**@bart.it> wrote:
我从数据库中收到一个utf8字符,如&#30000(日语
字符,样式:& #XXXXX)。
我如何可视化日语我的申请人物?我找到了类System.Text.Encoding,但输入看起来像\ uXXXX。我不知道该怎么做。
I receive an utf8 character from a database, like &#30000 (Japanese
Character, style: &#XXXXX).
How can I visualize the Japanese character on my application? I have found
the class System.Text.Encoding, but the input looks like \uXXXX. I don''t
know how to do.




我不完全确定你的意思是输入看起来像\ uXXXX ;。

你的意思是它作为带有\uXXXX的字符串存储在数据库中in?

你确定*关于那个,或者只是调试器是什么?
显示? (尝试将其写入控制台。)


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复该团体,请不要给我发邮件



I''m not entirely sure what you mean by "the input looks like \uXXXX".
Do you mean it''s stored in the database as a string with "\uXXXX" in?
Are you *sure* about that, or is that just what the debugger is
showing? (Try writing it out to the console.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too




" Jon Skeet [C#MVP]" < SK *** @ pobox.com>在消息中写道

新闻:MP ************************ @ msnews.microsoft.c om ...

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Bart< ba ** @ bart.it>写道:
Bart <ba**@bart.it> wrote:
我从数据库中收到一个utf8字符,如&#30000(日语
字符,样式:& #XXXXX)。
我如何可视化日语我的申请人物?我有
找到类System.Text.Encoding,但输入看起来像\uXXXX。我不知道该怎么做。
我不完全确定你的意思是输入看起来像\ uXXXX。
你的意思是'' s作为带有\uXXXX的字符串存储在数据库中in?
你确定*那个,或者只是调试器显示的内容? (尝试将其写入控制台。)
I receive an utf8 character from a database, like &#30000 (Japanese
Character, style: &#XXXXX).
How can I visualize the Japanese character on my application? I have found the class System.Text.Encoding, but the input looks like \uXXXX. I don''t
know how to do.
I''m not entirely sure what you mean by "the input looks like \uXXXX".
Do you mean it''s stored in the database as a string with "\uXXXX" in?
Are you *sure* about that, or is that just what the debugger is
showing? (Try writing it out to the console.)




我在MSDN Library上看过这个例子:


UTF8Encoding utf8 = new UTF8Encoding();

UTF8Encoding utf8ThrowException = new UTF8Encoding(false,true);


//此数组连续包含两个高代理项(\ uD801,

\ uD802)。

//高代理人应该跟一个低代理人。

Char [] chars = new Char [] {'''',''b'',''c'',''\ uD801'',''\ uD802'',''d''};


这意味着我必须将字符串写为\uXXXX,但在我的数据库中,

文件存储(utf8)为& #XXXXX。我不明白为什么在这个例子中,

utf8字符具有该格式,并且在我的数据库中有一个不同的字符,即使

都是utf8编码的。


- Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复小组,请不要给我发邮件



I have looked this example at MSDN Library:

UTF8Encoding utf8 = new UTF8Encoding();
UTF8Encoding utf8ThrowException = new UTF8Encoding(false, true);

// This array contains two high surrogates in a row (\uD801,
\uD802).
// A high surrogate should be followed by a low surrogate.
Char[] chars = new Char[] {''a'', ''b'', ''c'', ''\uD801'', ''\uD802'', ''d''};

It means that I have to write the strings as \uXXXX, but in my database the
file are stored (utf8) as &#XXXXX. I don''t understand why in the example an
utf8 character has that format and in my database a different one even if
are both utf8 encoded.


--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Bart< ba ** @ bart.it>写道:
Bart <ba**@bart.it> wrote:
" Jon Skeet [C#MVP]" < SK *** @ pobox.com>在消息中写道
新闻:MP ************************ @ msnews.microsoft.c om ...
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Bart< ba ** @ bart.it>写道:
Bart <ba**@bart.it> wrote:
我从数据库中收到一个utf8字符,如&#30000(日语
字符,样式:& #XXXXX)。
我如何可视化日语我的申请人物?我找到了类System.Text.Encoding,但输入看起来像\uXXXX。我不知道该怎么做。
I receive an utf8 character from a database, like &#30000 (Japanese
Character, style: &#XXXXX).
How can I visualize the Japanese character on my application? I have found the class System.Text.Encoding, but the input looks like \uXXXX. I don''t
know how to do.



我不完全确定你的意思是输入看起来像\ uXXXX。你确定*那个,或者只是调试器显示的内容? (尝试将其写入控制台。)



I''m not entirely sure what you mean by "the input looks like \uXXXX".
Do you mean it''s stored in the database as a string with "\uXXXX" in?
Are you *sure* about that, or is that just what the debugger is
showing? (Try writing it out to the console.)



我在MSDN Library上看过这个例子:

UTF8Encoding utf8 = new UTF8Encoding();
UTF8Encoding utf8ThrowException = new UTF8Encoding(false,true);

//此数组连续包含两个高代理项(\ uD801,
\ uD802)。
/ /一个高代理人应该跟一个低代理人。
Char [] chars = new Char [] {''a'','b'','c'',''\ uD801' ','''\ uD802'',''d''};

这意味着我必须将字符串写为\uXXXX,但在我的数据库中
文件是存储(utf8)as& #XXXXX。我不明白为什么在示例中
utf8字符具有该格式,并且在我的数据库中有一个不同的字符,即使
都是utf8编码。



I have looked this example at MSDN Library:

UTF8Encoding utf8 = new UTF8Encoding();
UTF8Encoding utf8ThrowException = new UTF8Encoding(false, true);

// This array contains two high surrogates in a row (\uD801,
\uD802).
// A high surrogate should be followed by a low surrogate.
Char[] chars = new Char[] {''a'', ''b'', ''c'', ''\uD801'', ''\uD802'', ''d''};

It means that I have to write the strings as \uXXXX, but in my database the
file are stored (utf8) as &#XXXXX. I don''t understand why in the example an
utf8 character has that format and in my database a different one even if
are both utf8 encoded.




我不确定你的意思是存储(utf8)as& #XXXXX。你的意思是

,实际的人物''&'''''''等在数据库中 - 或者它是b / b
就是这样的在显示它们时会看到非ASCII字符

在一个SQL查询执行环境中?


0xffff以上的Unicode字符必须存储在

.NET中的代理形式是.NET在内部使用UTF-16,有效地是
- 每个字符是16位,这不足以覆盖整个

Unicode。


当你在C#程序中写一个字符串时,你*可以*使用

\UXXXXXXXX相反(注意大写U)。只支持最大值为0x10ffff的值为

,因此前两个X将始终为0.


-

Jon Skeet - < sk *** @ pobox.com>
http:// www .pobox.com / ~siget

如果回复小组,请不要给我发邮件



I''m not sure what you mean by "stored (utf8) as &#XXXXX". Do you mean
that the actual characters ''&'' ''#'' etc are in the database - or is it
just that that''s how you see non-ASCII characters when displaying them
in (say) a SQL query execution environment?

The reason Unicode characters above 0xffff have to be stored in
surrogate form in .NET is that .NET uses UTF-16 internally, effectively
- each character is 16 bits, which isn''t enough to cover the whole of
Unicode.

When you write a string in a C# program, however, you *can* use
\UXXXXXXXX instead (note the capital U). Only values up to 0x10ffff are
supported, so the first two Xs will always be 0.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于差异/你和&amp;#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆