Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public static byte[] StringToCFString(string value)
  2. {
  3. byte[] b;
  4.  
  5. b = new byte[value.Length + 10];
  6. b[4] = 0x8c;
  7. b[5] = 07;
  8. b[6] = 01;
  9. b[8] = (byte)value.Length;
  10. Encoding.ASCII.GetBytes(value, 0, value.Length, b, 9);
  11. return b;
  12. }
  13.  
  14. public static byte[] StringToCString(string value)
  15. {
  16. byte[] bytes = new byte[value.Length + 1];
  17. Encoding.ASCII.GetBytes(value, 0, value.Length, bytes, 0);
  18. return bytes;
  19. }
  20.  
  21. public static string CFStringToString(byte[] value)
  22. {
  23. return Encoding.ASCII.GetString(value, 9, value[9]);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement