c# - Add byte order mark to a string via StringBuilder -
how can add byte order mark stringbuilder? (i have pass string method save file, can't modify method).
i tried this:
var sb = new stringbuilder(); sb.append('\xef'); sb.append('\xbb'); sb.append('\xbf');
but when view hex editor, adds following sequence: c3 af c2 bb c2 bf
the string huge, without , forth converting byte array.
edit: clarification after questions in comments. have pass string method takes string , creates file of on azure blob storage. can't modify other method.
two options:
- don't include byte order mark in text @ all... instead use encoding automatically include it
include as character in
stringbuilder
:sb.append('\ufeff'); // u+feff byte-order mark character
personally i'd go first approach normally, "i can't modify method" suggests may not option in case.
Comments
Post a Comment