[英]Write a Special Character in Rs232 connection in Java
I need send some special characters in a rs232 connection, but I'm with troubles. 我需要在rs232连接中发送一些特殊字符,但是我遇到了麻烦。
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 Â. 我检测到“ \\ u00BF”的零位置。getBytes()具有字符Â。 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!
谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.