Encode up to one byte extended ascii values

In C #, there is a way to encode extended ascii values ​​(128-255) into their single byte values, as shown here: http://asciitable.com/

I tried using Encoding.UTF8.GetBytes (), but it returns multibyte values ​​for extended codes. I need nothing but 255, but it would be nice to at least support them. I am trying to send text data to an Arduino controlled and LED matrix and want to process letters with an accent without dealing with multibyte characters.

EDIT: To clarify, the LED matrix does not have a special code page. That is basically all I say. There is no built-in text support or arduino. This is just a dumb display with a resolution of 128x8 pixels, and the controller manually draws a pixel of text by pixels. Therefore, I actually provide it with a font (like an array of bytes in the header file) and can make any character code match any of the results that I want ... therefore, which code page to use is not a problem, except which will give me full 8-bit characters.

+4
source share
3 answers

Just pass the code page number to the Encoding constructor. If you linked the correct "extended ASCII" table, it will be 437 .

But the IBM437 encoding is unusual outside of DOS programs and Windows console applications. Otherwise, the standard encoding for Western European languages ​​is ISO-8859-1 (Windows code 28591) or windows-1252 .

+4
source

You need to know the code page that the LED matrix uses. It should be standard, such as 1252, the Windows codepage for Western Europe and the Americas.

  var bytes = Encoding.GetEncoding(1252).GetBytes("Γ…Γ£rdvΓ‘rk"); 
+2
source

Default coding should handle this. Or use ANSI encoding / encoding.

+1
source

Source: https://habr.com/ru/post/1334635/


All Articles