C# zamiana z mozavia na utf8

Witam serdecznie,

Mam plik zapisany w Mazovi i chciałbym go przekonwertować na UTF8… znalazłem taki kod:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

using System.Collections;



namespace ConsoleApplication1

{

class Program

{


static void Main(string[] args)

{


string datatable;

string datatable2;

datatable2 = System.IO.File.ReadAllText("C:\\txt.txt");


Encoding mazoviaEnc = Encoding.GetEncoding(852);


byte[] mazoviaBytes = mazoviaEnc.GetBytes(datatable2);


string utf7str = Encoding.UTF7.GetString(


Encoding.Convert(mazoviaEnc, Encoding.UTF7, mazoviaBytes));


Console.WriteLine("abc: ", datatable2);

}

}

public class MazoviaEncoding : Encoding

{

private MazoviaEncoding() { }

private static MazoviaEncoding _encoding = null; public static Encoding Mazovia { get { if (_encoding == null) { _encoding = new MazoviaEncoding(); } return _encoding; } }

public override byte[] GetBytes(string s) { List data = new List(); foreach (char c in s) { data.Add(CharToByte(c)); } return data.ToArray(); }

public override string GetString(byte[] bytes, int index, int count)

{

if (bytes == null) { throw new NullReferenceException(); }

if (index < 0 || index + count > bytes.Length) { throw new IndexOutOfRangeException(); }

StringBuilder sb = new StringBuilder(); for (int i = index; i < index + count; i++) { if (bytes[i] == 0) { break; } sb.Append(ByteToChar(bytes[i])); } return sb.ToString();

}

private byte Cha;


}

}

ale niestety nie chce się to skompilować :frowning: Mógłbym prosić o pomoc z kompilacją tego?

Wyrzuca mi błąd:

Error 1 ‘ConsoleApplication1.MazoviaEncoding’ does not implement inherited abstract member ‘System.Text.Encoding.GetMaxCharCount(int)’ C:\Application1\Program.cs 32 18 ConsoleApplication1

Co robię nie tak??:frowning:

przeczytaj komunikat raz, potem drugi, potem trzeci aż w końcu domyślisz się że masz zaimplementować wszystkie metody Interfejsu Encoding.

Znalazłeś na innym forum urwany w połowie kod. Prościej byłoby tam spytać.