1. <tfoot id='uG5qm'></tfoot>
    • <bdo id='uG5qm'></bdo><ul id='uG5qm'></ul>

    <legend id='uG5qm'><style id='uG5qm'><dir id='uG5qm'><q id='uG5qm'></q></dir></style></legend>
    1. <small id='uG5qm'></small><noframes id='uG5qm'>

      <i id='uG5qm'><tr id='uG5qm'><dt id='uG5qm'><q id='uG5qm'><span id='uG5qm'><b id='uG5qm'><form id='uG5qm'><ins id='uG5qm'></ins><ul id='uG5qm'></ul><sub id='uG5qm'></sub></form><legend id='uG5qm'></legend><bdo id='uG5qm'><pre id='uG5qm'><center id='uG5qm'></center></pre></bdo></b><th id='uG5qm'></th></span></q></dt></tr></i><div id='uG5qm'><tfoot id='uG5qm'></tfoot><dl id='uG5qm'><fieldset id='uG5qm'></fieldset></dl></div>

      SerialPort 编码 - 我如何获得 8 位 ASCII?

      SerialPort encoding - how do I get 8 bit ASCII?(SerialPort 编码 - 我如何获得 8 位 ASCII?)

        <small id='EVPGT'></small><noframes id='EVPGT'>

        <i id='EVPGT'><tr id='EVPGT'><dt id='EVPGT'><q id='EVPGT'><span id='EVPGT'><b id='EVPGT'><form id='EVPGT'><ins id='EVPGT'></ins><ul id='EVPGT'></ul><sub id='EVPGT'></sub></form><legend id='EVPGT'></legend><bdo id='EVPGT'><pre id='EVPGT'><center id='EVPGT'></center></pre></bdo></b><th id='EVPGT'></th></span></q></dt></tr></i><div id='EVPGT'><tfoot id='EVPGT'></tfoot><dl id='EVPGT'><fieldset id='EVPGT'></fieldset></dl></div>
            <legend id='EVPGT'><style id='EVPGT'><dir id='EVPGT'><q id='EVPGT'></q></dir></style></legend>

                <tbody id='EVPGT'></tbody>
              <tfoot id='EVPGT'></tfoot>

                <bdo id='EVPGT'></bdo><ul id='EVPGT'></ul>
                本文介绍了SerialPort 编码 - 我如何获得 8 位 ASCII?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在使用通过串行端口进行通信的程序时遇到问题.它必须发送和接收的字符之一是度数符号,ASCII 0xBF.多年来一直运行良好,现在突然串行端口对象开始丢弃第 7 位,所以我得到的是 0x3F 而不是 0xBF.

                I'm having a problem with a program that communicates over a serial port. One of the characters it must send and receive is the degree symbol, ASCII 0xBF. It's been working fine for years now suddenly the serial port object has started dropping bit 7, so I get 0x3F instead of 0xBF.

                我确信这是我所做的一些愚蠢的事情,因为我最近在该领域修改了我的代码 - 但是我看不出我所做的会导致第 8 位丢失.

                I'm sure that this is something silly I've done because I've tinkered with my code in that area recenlty - however I cannot see what I've done that causes loss of the 8th bit.

                我的端口是这样初始化的:

                My port gets initialized like this:

                    BaudRate              9600  int  
                    DataBits              8 int  
                    DiscardNull true    bool
                    DtrEnable             true  bool
                    Encoding    {System.Text.ASCIIEncoding} System.Text.Encoding                  Handshake           None  System.IO.Ports.Handshake
                    NewLine           "
                "  string
                    Parity            None  System.IO.Ports.Parity
                    ParityReplace   63  byte
                    PortName              "COM4"    string
                    ReadBufferSize  128 int
                    ReadTimeout 250 int
                    ReceivedBytesThreshold  1   int
                    RtsEnable             true  bool
                    StopBits              One   System.IO.Ports.StopBits
                    WriteBufferSize 64  int
                    WriteTimeout    1500    int
                

                任何想法如何将端口恢复为 8 位操作?

                Any ideas how I restore the port to 8-bit operation?

                推荐答案

                你的问题是 ASCIIEncoding 是 7 位编码.您正在寻找支持扩展ASCII的东西.

                Your problem is that ASCIIEncoding is a 7 bit encoding. You're looking for something that supports Extended ASCII.

                以下内容将为您提供代码页1252.

                System.Text.Encoding.GetEncoding(1252);
                

                这将使您获得 ISO 8859-1.

                System.Text.Encoding.GetEncoding(28591);
                

                这两个都被认为是 扩展 ASCII 并且都包含通常与此相关的符号(大多数具有相同的字节表示)设置,例如 ©, ¥, 和 º.有关每种编码中包含哪些字符的详细信息,请参阅参考链接.

                Both of these are considered Extended ASCII and both contain symbols (mostly with the same byte representation) typically associated with this set, such as © , ¥ , and º . See the referenced links for more information about which characters are included in each encoding.

                这篇关于SerialPort 编码 - 我如何获得 8 位 ASCII?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                How to store delegates in a List(如何将代表存储在列表中)
                How delegates work (in the background)?(代表如何工作(在后台)?)
                C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
                  <tbody id='sJUdX'></tbody>
                <legend id='sJUdX'><style id='sJUdX'><dir id='sJUdX'><q id='sJUdX'></q></dir></style></legend>
                • <small id='sJUdX'></small><noframes id='sJUdX'>

                        <bdo id='sJUdX'></bdo><ul id='sJUdX'></ul>
                        <tfoot id='sJUdX'></tfoot>

                          <i id='sJUdX'><tr id='sJUdX'><dt id='sJUdX'><q id='sJUdX'><span id='sJUdX'><b id='sJUdX'><form id='sJUdX'><ins id='sJUdX'></ins><ul id='sJUdX'></ul><sub id='sJUdX'></sub></form><legend id='sJUdX'></legend><bdo id='sJUdX'><pre id='sJUdX'><center id='sJUdX'></center></pre></bdo></b><th id='sJUdX'></th></span></q></dt></tr></i><div id='sJUdX'><tfoot id='sJUdX'></tfoot><dl id='sJUdX'><fieldset id='sJUdX'></fieldset></dl></div>