问题描述
在C#有没有办法来扩展ASCII值(128-255)编码成它们的单字节值,如下所示:
In C# is there a way to encode the extended ascii values (128-255) into their single byte values as shown here: http://asciitable.com/
我已经使用Encoding.UTF8.GetBytes试过(),但是,对于扩展的代码返回多字节值。我不需要任何超越255,但它会是不错的,至少支持这些。我想发送文本数据,一个Arduino运行和LED矩阵,并要处理重音字母,而不必处理多字节字符。
I've tried using Encoding.UTF8.GetBytes() but that returns multi byte values for the extended codes. I don't need anything beyond 255, but it would be nice to at least support those. I'm trying to send the text data to an Arduino running and LED matrix and want to handle accented letters, without having to deal with multibyte characters.
修改为了澄清,LED矩阵没有具体的代码页。它基本上不管我说是。有没有建在它或Arduino的文本支持。这只是一个愚蠢的128x8像素的显示屏和控制器是手工绘制由像素文本像素。因此,实际上,我提供的字体(如在头文件的字节数组),它并可以使任何字符代码对应,我想任何输出......所以,它的代码页使用的是不是真的比其他的问题哪一个给我完整的8位字符。
To clarify, the LED matrix has no specific codepage. It's basically whatever I say it is. There's no built in text support in it or the arduino. It's just a dumb 128x8 pixel display and the controller is manually drawing the text pixel by pixel. Therefore, I'm actually providing a font (as a byte array in a header file) to it and can make any character code correspond to any output that I want... so, which codepage to use is not really an issue other than which one will give me full 8-bit characters.
推荐答案
只是通过代码页号的编码
构造函数。如果您链接什么是正确的扩展ASCII表,这将是。
Just pass the code page number to the Encoding
constructor. If what you linked is the correct "extended ASCII" table, that would be 437.
不过IBM437编码是不常见的DOS程序和Windows控制台应用程序之外。否则,对于西欧语言的标准编码是(视窗代码页28591)或。
But IBM437 encoding is uncommon outside of DOS programs and Windows console apps. Otherwise, the standard encoding for Western European languages is ISO-8859-1 (Windows code page 28591) or windows-1252.
这篇关于编码为单字节扩展ASCII值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!