CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Posts
    18

    hex numbers (unicode) to String

    Hi,

    1. I want to convert some Hex numbers which contain unicode vallues into a string, Say, I have

    0x0 0x0 0x4 0x2 which means "b" (I think)

    I want to get a string containing "b".

    I tried this:
    -------------------------------------------
    byte[] b = {0x0, 0x0 ,0x4 ,0x2};

    System.Text.Encoding u = new System.Text.UnicodeEncoding();

    string h = u.GetString(b);
    --------------------------------------------

    but the returned string equals "".

    2. How can I convert an int or such to a hex-String ? Like I have int i = 0; and I want to get a string containing "0x0".


    Thanks for you time !

    regards, Lobo

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125
    Multi byte numbers are stored LittleEndian on PCs!
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Dec 2002
    Posts
    18

    got it.

    Thanks, the problem was the bytearray (not 0x4, 0x2 but 0x42).

    Thanks anyway!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured