예제 #1
0
 public static string FromFileCp1251ToUtf8String(string path)
 {
     var sb = new StringBuilder();
     using (var reader = new StreamReader(File.OpenRead(path), Encoding.GetEncoding(1251)))
     using (var writer = new Utf8StringWriter(sb))
     {
         writer.Write(reader.ReadToEnd());
         return sb.ToString();
     }
 }
예제 #2
0
 public static string FromStreamUtf8ToStringUtf8(MemoryStream ms)
 {
     var sb = new StringBuilder();
     using (var reader = new StreamReader(ms, Encoding.UTF8))
     using (var writer = new Utf8StringWriter(sb))
     {
         writer.Write(reader.ReadToEnd());
         return sb.ToString();
     }
 }