Repository navigation
Replies: 2 comments 1 reply
|
What is return ms.ToArray(); |
|
The problem is the BOM. // UTF8Encoding(true) = emit the BOM. Encoding.UTF8 does NOT emit one.
var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: true);
using var ms = new MemoryStream();
using (var writer = new StreamWriter(ms, encoding, leaveOpen: true))
using (var csv = new CsvWriter(writer, new CsvConfiguration(CultureInfo.InvariantCulture)
{
Encoding = encoding
}))
{
csv.WriteRecords(records);
}
return File(ms.ToArray(), "text/csv", "test.csv");Two things to check: the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi @JoshClose ..
Many thanks for this wonderful library. We have been using this for long time. Great work and efforts by you.
Recently we noticed that when we download csv with Korean characters and open it in Excel, we see a some symbols instead of actual Korean text. From the Github Issues, I noticed that this might be related to some encoding issue and tried adding UTF-8 Encoding but there is a difference in behaviour.
It works (meaning after saving the file when I open in excel everything looks good.) when I directly save as file as shown below
But when I use the same logic and download as csv from asp.net core and open it boom... I see symbols instead of Korean characters.
Please can you assist me on what I'm missing?
All reactions