public static byte[] GetBytes(string str) { try { return Encoding.UTF8.GetBytes(str); } catch (IOException e) { throw new Exception("string to UTF-8 conversion failed: " + e.Message); } }