This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (35 loc) · 1.28 KB
/
Program.cs
File metadata and controls
40 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.IO;
using System.Text;
using DelimitedDataParser;
namespace WindowsEncoding
{
internal class Program
{
private static void Main()
{
// If code page based character encodings are required when using
// DelimitedDataParser in a .NET Core app, be sure to include the
// NuGet package System.Text.Encoding.CodePages.
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
// Attempting to obtain the Windows-1252 encoding will fail on .NET Core
// if the required code page based encoding is not correctly registered.
var windows1252 = Encoding.GetEncoding(1252);
// Try and ensure the console's encoding matches the character encoding
// of the file input data.
Console.OutputEncoding = windows1252;
var parser = new Parser
{
UseFirstRowAsColumnHeaders = false
};
using (var stream = new StreamReader("Windows1252.txt", windows1252))
using (var reader = parser.ParseReader(stream))
{
while (reader.Read())
{
Console.WriteLine(reader[0]);
}
}
}
}
}