Created
January 18, 2015 22:36
-
-
Save aliostad/e9e0cad7386a95c57401 to your computer and use it in GitHub Desktop.
Turns UTF-8 hex representation of the character to its Unicode code in Little Endian
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hex = "d8a7"; | |
var utf8 = Enumerable.Range(0, hex.Length) | |
.Where(x => x % 2 == 0) | |
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16)) | |
.ToArray(); | |
var s = Encoding.UTF8.GetString(utf8); | |
var uni = Encoding.Unicode.GetBytes(s); | |
Console.WriteLine("0x" + string.Join("", uni.Reverse().Select(x => x.ToString("X")))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment