Skip to content

Instantly share code, notes, and snippets.

@dinowang
Last active June 20, 2018 09:15
Show Gist options
  • Save dinowang/e1afbf995eb530f4ab6bd45d2af0a744 to your computer and use it in GitHub Desktop.
Save dinowang/e1afbf995eb530f4ab6bd45d2af0a744 to your computer and use it in GitHub Desktop.
C# convert string to hexadecimal string
var str = "1234中文";
var hex = string.Join("", Encoding.GetEncoding("BIG5").GetBytes(str).Select(x => $"{x:X2}"));
// hex = "31323334A4A4A4E5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment