Hier, mal eben zusammengeschrieben, hoffe es hilft dir
C#Alles anzeigenusing System; using System.Text; using System.Collections.Generic; public class HelloWorld { private static IReadOnlyDictionary<string, string> SPECIAL_DIACRITICS = new Dictionary<string, string> { { "ä".Normalize(NormalizationForm.FormD), "{".Normalize(NormalizationForm.FormD) }, { "Ä".Normalize(NormalizationForm.FormD), "[".Normalize(NormalizationForm.FormD) }, { "ö".Normalize(NormalizationForm.FormD), "|".Normalize(NormalizationForm.FormD) }, { "Ö".Normalize(NormalizationForm.FormD), "\\".Normalize(NormalizationForm.FormD) }, { "ü".Normalize(NormalizationForm.FormD), "}".Normalize(NormalizationForm.FormD) }, { "Ü".Normalize(NormalizationForm.FormD), "]".Normalize(NormalizationForm.FormD) }, { "ß".Normalize(NormalizationForm.FormD), "~".Normalize(NormalizationForm.FormD) }, }; public static void Main(string[] args) { String newAnzeige = "zA1Tägel"; Console.OutputEncoding = Encoding.UTF8; Console.WriteLine(PrepareMessage(newAnzeige)); } private static String PrepareMessage(String xMessage) { var stringBuilder = new StringBuilder(xMessage.Normalize(NormalizationForm.FormD)); foreach (var keyValuePair in SPECIAL_DIACRITICS) { stringBuilder.Replace(keyValuePair.Key, keyValuePair.Value); } stringBuilder.Append(CalculateChecksum(xMessage)); return stringBuilder.ToString(); } private static byte CalculateChecksum(String xMessage) { xMessage += 0x0D; byte checksum = 0x7F; byte[] bytes = Encoding.ASCII.GetBytes(xMessage); foreach (byte b in bytes) { checksum ^= b; } return checksum; } }
Das sieht schonmal Klasse aus, danke dir dafür. Aktuell zeigt er mir allerdings noch folgendes Problem an,
System.IO.IOException
HResult=0x80070006
Nachricht = Das Handle ist ungültig.
Quelle = mscorlib
Stapelüberwachung:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIOError()
at System.Console.set_OutputEncoding(Encoding value)
at Ibis.net_2.Form1.pictureBox1_Click(Object sender, EventArgs e) in C:\Users\user\source\repos\Ibis .net 2\Ibis .net 2\Form1.cs:line 1247
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Ibis.net_2.Program.Main() in C:\Users\user\source\repos\Ibis .net 2\Ibis .net 2\Program.cs:line 19
handelt sich um einen Fehler bei