Skip to content

Commit

Permalink
Make CSV writing and reading use the Invariant culture. Fixes YarnSpi…
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Feb 1, 2020
1 parent 38104d3 commit 35a6c11
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
14 changes: 13 additions & 1 deletion Editor/YarnImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,22 @@ private void ImportYarn(AssetImportContext ctx)
}

if (stringTable.Count > 0) {



using (var memoryStream = new MemoryStream())
using (var textWriter = new StreamWriter(memoryStream)) {
// Generate the localised .csv file
var csv = new CsvHelper.CsvWriter(textWriter);

// Use the invariant culture when writing the CSV
var configuration = new CsvHelper.Configuration.Configuration(
System.Globalization.CultureInfo.InvariantCulture
);

var csv = new CsvHelper.CsvWriter(
textWriter, // write into this stream
configuration // use this configuration
);

var lines = stringTable.Select(x => new {
id = x.Key,
Expand Down
9 changes: 7 additions & 2 deletions Scripts/DialogueRunner.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
The MIT License (MIT)
Expand Down Expand Up @@ -369,8 +369,13 @@ public void AddStringTable(YarnProgram yarnScript) {
textToLoad = yarnScript.baseLocalisationStringTable;
}

// Use the invariant culture when parsing the CSV
var configuration = new CsvHelper.Configuration.Configuration(
System.Globalization.CultureInfo.InvariantCulture
);

using (var reader = new System.IO.StringReader(textToLoad.text))
using (var csv = new CsvReader(reader)) {
using (var csv = new CsvReader(reader, configuration)) {
csv.Read();
csv.ReadHeader();

Expand Down

0 comments on commit 35a6c11

Please sign in to comment.