c# unicode question

  • Thread starter Thread starter Yang,Jun
  • Start date Start date
Y

Yang,Jun

--
Hi,all
if i wirte
string str =
"\u6570\u636e\u5e93\u64cd\u4f5c\u95ee\u9898\uff0c\u8bf7\u60a8\u91cd\u65b0\u7
67b\u5f55\uff01";
dotNet can recognize as unicode ,and when i console.write() it , it can
show right chinese words.
but if i read this sentence from TextBox,dotNet will add @ , like str=
@"\u6570...";
When i console.write() ,i only can see "\u6570..." but not chinese words.

So,

is there any way to convert the string added @ to normal string ?
or i have to write a function to read every char and re-write to another
string ?

thx very much

Best Regards,
Yang,Jun (e-mail address removed)-labs.com
 
dotNet will add @ , like str= @"\u6570...";

This will happen if you are setting the "Text" property using a designer since the PropertiesGrid control (used by VS.NET) will not
take escaped strings as input. Instead, set the property in code.
 
Yang said:
Hi,all
if i wirte
string str =
"\u6570\u636e\u5e93\u64cd\u4f5c\u95ee\u9898\uff0c\u8bf7\u60a8\u91cd\u65b0\u7
67b\u5f55\uff01";
dotNet can recognize as unicode ,and when i console.write() it , it can
show right chinese words.
but if i read this sentence from TextBox,dotNet will add @ , like str=
@"\u6570...";
When i console.write() ,i only can see "\u6570..." but not chinese words.

Nope, it works fine in a textbox too - but only if you have the code
above. If you use the designer, you can't use the escape mechanisms as
above; it will automatically escape things for you.
 
Back
Top