Skip to content

Commit ee19e46

Browse files
committed
修正命令方式執行結果錯誤的問題
1 parent 8111cd7 commit ee19e46

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ConvertZZ/App.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private void Application_Startup(object sender, StartupEventArgs e)
164164
{
165165
using (Stream stream = new FileStream(f, FileMode.Open, FileAccess.Read, FileShare.Read))
166166
{
167-
using (StreamReader streamReader = new StreamReader(stream))
167+
using (StreamReader streamReader = new StreamReader(stream, encoding[0], false))
168168
{
169169
s = streamReader.ReadToEnd();
170170
}
@@ -187,7 +187,7 @@ private void Application_Startup(object sender, StartupEventArgs e)
187187
s = ConvertHelper.FileConvert(s, encoding, ToChinese, VocabularyCorrection);
188188
if (ModeIsOneFile)
189189
{
190-
using (StreamWriter streamWriter = new StreamWriter(path2))
190+
using (StreamWriter streamWriter = new StreamWriter(path2, false, encoding[1] == Encoding.UTF8 ? new UTF8Encoding(App.Settings.FileConvert.UnicodeAddBom) : encoding[1]))
191191
{
192192
streamWriter.Write(s);
193193
streamWriter.Flush();
@@ -210,7 +210,7 @@ private void Application_Startup(object sender, StartupEventArgs e)
210210
}
211211

212212
Directory.CreateDirectory(Path.GetDirectoryName(@string));
213-
using (StreamWriter streamWriter = new StreamWriter(@string))
213+
using (StreamWriter streamWriter = new StreamWriter(@string, false, encoding[1] == Encoding.UTF8 ? new UTF8Encoding(App.Settings.FileConvert.UnicodeAddBom) : encoding[1]))
214214
{
215215
streamWriter.Write(s);
216216
streamWriter.Flush();
@@ -219,7 +219,7 @@ private void Application_Startup(object sender, StartupEventArgs e)
219219
else
220220
{
221221
Directory.CreateDirectory(Path.GetDirectoryName(path2));
222-
using (StreamWriter streamWriter = new StreamWriter(Path.Combine(Path.GetDirectoryName(path2), Path.GetFileName(f))))
222+
using (StreamWriter streamWriter = new StreamWriter(Path.Combine(Path.GetDirectoryName(path2), Path.GetFileName(f)), false, encoding[1] == Encoding.UTF8 ? new UTF8Encoding(App.Settings.FileConvert.UnicodeAddBom) : encoding[1]))
223223
{
224224
streamWriter.Write(s);
225225
streamWriter.Flush();

0 commit comments

Comments
 (0)