I have a problem that output string must be utf8-formatted, I am writing currently ansi string to zip file without problems like this:
StreamReader tr = new StreamReader( "myutf8-file.xml");
String myfilecontent = tr.ReadToEnd();
ZipFile zip = new ZipFile());
zip.AddFileFromString("my.xml", "", myfilecontent );
How to force string (my.xml file content) to be UTF8.
Don’t use the deprecated
AddFileFromStringmethod. UseAddEntry(string, string, string, Encoding)instead:If you’re actually reading a UTF-8 text file to start with though, why not just open the stream and pass that into
AddEntry? There’s no need to decode from UTF-8 and then re-encode…