Use Ascii Encoding For Translation (#144)
* bug fix * delete unnecessary using * mistyped string * nonempty fallbackexception * update * fix
This commit is contained in:
Родитель
76ec796141
Коммит
ffc520c1d7
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Cilsil
|
||||
{
|
||||
|
@ -100,7 +101,14 @@ namespace Cilsil
|
|||
|
||||
(var cfg, var tenv) = ExecuteTranslation(paths, extprogress);
|
||||
|
||||
File.WriteAllText(cfgtxt ?? "./cfg.txt", cfg.ToString());
|
||||
var Utf8Encoder = Encoding.GetEncoding(
|
||||
"us-ascii",
|
||||
new EncoderReplacementFallback("_"),
|
||||
new DecoderExceptionFallback()
|
||||
);
|
||||
|
||||
|
||||
File.WriteAllText(cfgtxt ?? "./cfg.txt", cfg.ToString(), Utf8Encoder);
|
||||
cfg.WriteToFile(outcfg);
|
||||
tenv.WriteToFile(outtenv);
|
||||
|
||||
|
@ -201,7 +209,7 @@ namespace Cilsil
|
|||
return (filteredAssemblies, totalSize);
|
||||
}
|
||||
|
||||
private static void PrintFiles(string[] files = null, string procs = null)
|
||||
private static void PrintFiles(string[] files, string procs)
|
||||
{
|
||||
foreach (var file in files)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ using QuickGraph.Graphviz.Dot;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Cilsil.Sil
|
||||
{
|
||||
|
@ -109,8 +110,20 @@ namespace Cilsil.Sil
|
|||
/// <param name="path">The file path.</param>
|
||||
public void WriteToFile(string path)
|
||||
{
|
||||
var ascii = Encoding.GetEncoding(
|
||||
"us-ascii",
|
||||
new EncoderReplacementFallback("_"),
|
||||
new DecoderReplacementFallback("|")
|
||||
);
|
||||
var serializer = JsonSerializer.Create(JsonSerializerSettings);
|
||||
using (var streamWriter = new StreamWriter(path ?? "./cfg.json"))
|
||||
|
||||
var output = path ?? "./cfg.json";
|
||||
if (File.Exists(output))
|
||||
{
|
||||
File.Delete(output);
|
||||
}
|
||||
using (var fs = File.Open(output, FileMode.CreateNew, FileAccess.Write))
|
||||
using (var streamWriter = new StreamWriter(fs, ascii))
|
||||
using (var writer = new JsonTextWriter(streamWriter))
|
||||
{
|
||||
serializer.Serialize(writer, this);
|
||||
|
|
|
@ -7,6 +7,7 @@ using Newtonsoft.Json.Serialization;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Cilsil.Sil
|
||||
{
|
||||
|
@ -74,8 +75,21 @@ namespace Cilsil.Sil
|
|||
/// <param name="path">The file path.</param>
|
||||
public void WriteToFile(string path)
|
||||
{
|
||||
var ascii = Encoding.GetEncoding(
|
||||
"us-ascii",
|
||||
new EncoderReplacementFallback("_"),
|
||||
new DecoderReplacementFallback("|")
|
||||
);
|
||||
|
||||
var serializer = JsonSerializer.Create(JsonSerializerSettings);
|
||||
using (var streamWriter = new StreamWriter(path ?? "./tenv.json"))
|
||||
|
||||
var output = path ?? "./tenv.json";
|
||||
if (File.Exists(output))
|
||||
{
|
||||
File.Delete(output);
|
||||
}
|
||||
using (var fs = File.Open(output, FileMode.CreateNew, FileAccess.Write))
|
||||
using (var streamWriter = new StreamWriter(fs, encoding: ascii))
|
||||
using (var writer = new JsonTextWriter(streamWriter))
|
||||
{
|
||||
serializer.Serialize(writer, this);
|
||||
|
|
Загрузка…
Ссылка в новой задаче