Input encoding and tabulation
This commit is contained in:
@@ -15,4 +15,8 @@
|
|||||||
<None Remove="Model\NewFile1.txt" />
|
<None Remove="Model\NewFile1.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -25,20 +25,20 @@ namespace BoerseDataConvert
|
|||||||
public string ConvertToXml(Record record)
|
public string ConvertToXml(Record record)
|
||||||
{
|
{
|
||||||
StringBuilder xmlRecord = new StringBuilder();
|
StringBuilder xmlRecord = new StringBuilder();
|
||||||
xmlRecord.Append($" <record id=”{count}”>\n");
|
xmlRecord.Append($" <record id=”{count}”>\n");
|
||||||
foreach (var tagValue in record.TagsValues)
|
foreach (var tagValue in record.TagsValues)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string tag =CheckTagValue(tagValue.Key, tagValue.Value);
|
string tag =CheckTagValue(tagValue.Key, tagValue.Value);
|
||||||
xmlRecord.Append($" <{tag}>{tagValue.Value}</{tag}>\n");
|
xmlRecord.Append($" <{tag}>{tagValue.Value}</{tag}>\n");
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (ArgumentException e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xmlRecord.Append($" </record>");
|
xmlRecord.Append($" </record>");
|
||||||
count++;
|
count++;
|
||||||
return xmlRecord.ToString();
|
return xmlRecord.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace BoerseDataConvert
|
|||||||
public Reader(string adr, string[] filesNames)
|
public Reader(string adr, string[] filesNames)
|
||||||
{
|
{
|
||||||
fileInd = 0;
|
fileInd = 0;
|
||||||
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}");
|
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}", CodePagesEncodingProvider.Instance.GetEncoding(1252), true);
|
||||||
this.adr = adr;
|
this.adr = adr;
|
||||||
this.filesNames = filesNames;
|
this.filesNames = filesNames;
|
||||||
reader.ReadLine();
|
reader.ReadLine();
|
||||||
@@ -28,7 +28,7 @@ namespace BoerseDataConvert
|
|||||||
{
|
{
|
||||||
fileInd++;
|
fileInd++;
|
||||||
reader.Close();
|
reader.Close();
|
||||||
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}");
|
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}", CodePagesEncodingProvider.Instance.GetEncoding(1252), true);
|
||||||
RecordController.NextFile(filesNames[fileInd]);
|
RecordController.NextFile(filesNames[fileInd]);
|
||||||
s = reader.ReadLine();
|
s = reader.ReadLine();
|
||||||
s = reader.ReadLine();
|
s = reader.ReadLine();
|
||||||
|
|||||||
Reference in New Issue
Block a user