I am using UTF-8 encoding to try and send a byte array from my android application to my .NET server.
In my eclipse code(java) I retrieve the byte array from my database then I convert it to a UTF-8 string before sending it to the server.
byte[] b = db.getMyByteArray();
try
{
s = new String(b, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
I have no problems with sending the data. It gets to my server through an HTTP POST and I use the following c# code to try and convert the string back to a byte array.
Byte[] bytesUTF8 = System.Text.Encoding.UTF8.GetBytes(x.Signature);
However after comparing the bytes they are not the same.
Is there something I am doing wrong? Do I need to use a different method to send byte arrays to my server?
I figured out my own question. The solution was to send the byte array as a JSON array instead of trying to convert it to a string.