code_junkie

How do I know what encoding scheme to use when converting a string to a byte array

Nov 13th, 2011
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. public static byte[] StringToByteArray1(string str)
  2. {
  3. return Encoding.ASCII.GetBytes(str);
  4. }
  5.  
  6. public static byte[] StringToByteArray2(string str)
  7. {
  8. return Encoding.UTF8.GetBytes(str);
  9. }
Add Comment
Please, Sign In to add comment