Skip to content

Instantly share code, notes, and snippets.

@milovidov983
Created August 14, 2018 13:49
Show Gist options
  • Select an option

  • Save milovidov983/e6bd83028d694cc0c2c8d647b94a99d1 to your computer and use it in GitHub Desktop.

Select an option

Save milovidov983/e6bd83028d694cc0c2c8d647b94a99d1 to your computer and use it in GitHub Desktop.
How to convert UTF-8 to UTF-8 with BOM c# string
private string ConvertStringToUtf8Bom(string source) {
var data = Encoding.UTF8.GetBytes(source);
var result = Encoding.UTF8.GetPreamble().Concat(data).ToArray();
var encoder = new UTF8Encoding(true);
return encoder.GetString(result);
}
@luanrem

luanrem commented Mar 22, 2023

Copy link
Copy Markdown

Thanks guys! This helped!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment