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

    From UTF8 sting to byte array and vice versa

    Hello

    I have a byte array (first_arr) I changed it to UTF8 string like this
    Code:
    string utf_str = Encoding.UTF8.GetString(first_arr);
    Then I re-transferred it to byte array like this
    Code:
    byte [] second_arr = Encoding.UTF8.GetBytes(utf_str);
    But the resulted array (second_arr) is different from the native one (first_arr) Why does that happen?

  2. #2
    Join Date
    Oct 2013
    Posts
    16

    Re: From UTF8 sting to byte array and vice versa

    Probably the first array was of a different encoding, try using ASCII or Default

Tags for this Thread

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