Search code examples
androidencodingadb

Encoding issues using ADB to dispatch messages


I've implemented a service that listens to commands issued through ADB. An example of a command sent through ADB could look like this:

adb shell am startservice -a com.testandroid.SEND_SMS -e number 123123123 -e message "åäö"

Now, the problem here is that the encoding of the string "åäö" seems to mess up. If I take that string extras and immediately output it to the log, I get a square "[]", unknown character. If I send this message I get chinese characters in the messages app. As long as I stick to non-umlaut characters (ASCII I guess), everything works fine.

I'm using Windows 7 and the command line for this. I have not touched the encoding of the command line and I've tried to process the extras string by getting the byte characters, passing in UTF-8 as an encoding argument, then creating a new String passing in UTF-8 as an encoding argument there as well. No dice, though.

The values of the bytes, when using getBytes() are å: -27, ä: -92, ö: -74

How do I get this to play nice so I can make use of at least the umlauts?

All of this works perfectly fine in Linux.


Solution

  • Concluding, either the problem is situated in cmd.exe or adb.exe. Until either one or both are updated to be more compliant with eachother I will sadly not be able to make use of this for the time being.