简体   繁体   中英

Android/Java Send a http post request with chars not reformatted as UTF-8

In an Android app I need to use a http post request to talk to a D-Link W215. I'm basically making a java version o fthe code found here: http://www.devttys0.com/2014/05/hacking-the-d-link-dsp-w215-smart-plug/ . The problem is that one of the bytes I need to send is 0xAC and when it is sent over the network through java, it is received as unicode character \\00ac which are hex characters 0xC2 0xAC. Is there a way to have byte 0xAC actually sent. Thanks.

Edit: I also have confirmed that the problem is when the bytes are sent as the data is correct when I check it before I send it.

Use the following code.

byte[] message = {0xAC};
Socket socket = ...
DataOutputStream dOut = new DataOutputStream(socket.getOutputStream());
dOut.write(message);   

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