c# unicode question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yang,Jun

    c# unicode question



    --
    Hi,all
    if i wirte
    string str =
    "\u6570\u636e\u 5e93\u64cd\u4f5 c\u95ee\u9898\u ff0c\u8bf7\u60a 8\u91cd\u65b0\u 7
    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 yangj@blrcsv.ch ina.bell-labs.com


  • Dave

    #2
    Re: c# unicode question

    > 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.

    --
    Dave Sexton
    dave@www..jwaon line..com
    -----------------------------------------------------------------------
    "Yang,Jun" <yangj@blrcsv.c hina.bell-labs.com> wrote in message news:O$oBd%23xZ FHA.1040@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    >
    >
    > --
    > Hi,all
    > if i wirte
    > string str =
    > "\u6570\u636e\u 5e93\u64cd\u4f5 c\u95ee\u9898\u ff0c\u8bf7\u60a 8\u91cd\u65b0\u 7
    > 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 yangj@blrcsv.ch ina.bell-labs.com
    >
    >[/color]


    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: c# unicode question

      Yang,Jun <yangj@blrcsv.c hina.bell-labs.com> wrote:[color=blue]
      > Hi,all
      > if i wirte
      > string str =
      > "\u6570\u636e\u 5e93\u64cd\u4f5 c\u95ee\u9898\u ff0c\u8bf7\u60a 8\u91cd\u65b0\u 7
      > 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.[/color]

      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.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      Working...