简体   繁体   中英

Write a Special Character in Rs232 connection in Java

I need send some special characters in a rs232 connection, but I'm with troubles.

For example, when I want send the character ¿ I write:

OutputStream outputStream = null;
outputStream.write("\u00BF".getBytes());
outputStream.flush();

The receiver receive two characteres (¿) and I don't know why. When I send normal characteres all runs well.

Anyone have any idea of what's wrong? Thanks.

Solved!

I detect that in zero position of "\¿".getBytes() has the character Â. Why? I have no idea!

So, I write only the first position:

OutputStream outputStream = null;
outputStream.write("\u00BF".getBytes()[1]);
outputStream.flush();

This only happens in the special characters, in the normal I can write the zero position. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM