Unicode String Constants

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • B Dring

    Unicode String Constants

    I am trying to make a bunch of unicode constant strings. I am trying
    the following without success. Below is an example. Bad means that I
    get the following error "unclosed string literal". Is this due to the
    fact that 22hex is the ascii 34 double quote character? If so how do
    i work around?

    Note: They are not for display, they are for commands to be sent to a
    server.

    protected final static String CD0 = "", //OK
    CD1 = "\u0000\u00 01", // OK
    CD2 = "\u0002\u00 04", // OK
    CD3 = "\u0002\u00 12", // OK
    CD4 = "\u0002\u00 0c", // OK
    CD5 = "\u0002\u00 22", // BAD
    CD6 = "\u0002\u00 c0"; // OK
  • Benny

    #2
    Re: Unicode String Constants

    Hi,
    When we are using unicode escape in the program, there is a
    process which translates this unicode escape characters before the
    compilation. Due to the fact that CD5 is translated as """ which is a
    illegal, so you have to escape the " character by writing it as "\"".
    So I think CD5 should be "\u0002\u005c\u 0022". Hope this can help you.

    Benny

    bdring@comcast. net (B Dring) wrote in message news:<a4080921. 0308261836.79f8 4a6a@posting.go ogle.com>...[color=blue]
    > I am trying to make a bunch of unicode constant strings. I am trying
    > the following without success. Below is an example. Bad means that I
    > get the following error "unclosed string literal". Is this due to the
    > fact that 22hex is the ascii 34 double quote character? If so how do
    > i work around?
    >
    > Note: They are not for display, they are for commands to be sent to a
    > server.
    >
    > protected final static String CD0 = "", //OK
    > CD1 = "\u0000\u00 01", // OK
    > CD2 = "\u0002\u00 04", // OK
    > CD3 = "\u0002\u00 12", // OK
    > CD4 = "\u0002\u00 0c", // OK
    > CD5 = "\u0002\u00 22", // BAD
    > CD6 = "\u0002\u00 c0"; // OK[/color]

    Comment

    • Klaus

      #3
      Re: Unicode String Constants

      Why don't you use a char array?

      char CD5[] = {'\u0002','\u00 22'};

      This should work.

      Comment

      Working...