Make CSV files UTF-8 w/o BOM (#4196)

This commit is contained in:
ptrstr 2024-03-02 14:56:10 -05:00 committed by GitHub
parent 0f936f88f4
commit 4f26560233
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using PKHeX.Core; using PKHeX.Core;
@ -116,7 +117,7 @@ public partial class ReportGrid : Form
private async Task Export_CSV(string path) private async Task Export_CSV(string path)
{ {
await using var fs = new FileStream(path, FileMode.Create); await using var fs = new FileStream(path, FileMode.Create);
await using var s = new StreamWriter(fs, System.Text.Encoding.Unicode); await using var s = new StreamWriter(fs, new UTF8Encoding(false));
var headers = dgData.Columns.Cast<DataGridViewColumn>(); var headers = dgData.Columns.Cast<DataGridViewColumn>();
await s.WriteLineAsync(string.Join(",", headers.Skip(1).Select(column => $"\"{column.HeaderText}\""))).ConfigureAwait(false); await s.WriteLineAsync(string.Join(",", headers.Skip(1).Select(column => $"\"{column.HeaderText}\""))).ConfigureAwait(false);