Skip to content

Instantly share code, notes, and snippets.

@russau
Created September 6, 2012 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russau/3655520 to your computer and use it in GitHub Desktop.
Save russau/3655520 to your computer and use it in GitHub Desktop.
De-Mojibake
byte[] badBytes = new byte[] { 0x44, 0x6f, 0x72, 0x66, 0x73, 0x74, 0x72, 0x61, 0xc3, 0x83, 0xc5, 0xb8, 0x65 }; //Dorfstraße
string utf8 = System.Text.Encoding.UTF8.GetString(badBytes);
byte[] fixedBytes = System.Text.Encoding.GetEncoding(1252).GetBytes(utf8);
string allGood = System.Text.Encoding.UTF8.GetString(fixedBytes); //Dorfstraße
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment