Why is the "@" symbol being translated to "¿" when sent via SMS from an Android 2.3 device?

15

I'm developing an application for Android that sends commands to a remote device via SMS. The commands used are all common text messages, and some of them are started with the prefix A@@ . To test the application I have sent some "commands" to an Android 4.3 phone and an Android 2.3.

When I run the application on Android 4.3, SMS is normally received on any device, but if I use the application to send commands from an Android 2.3 the commands are received as A¿¿ by the Android 4.3 phone but arrive normally as A@@ on both an Android 2.3 and an iPhone. In the "target" device, which uses a GSM modem, the message arrives as A (character "A" plus 2 spaces - ASCII symbol 0x20), so I suspect sending is using an encoding different. The strange thing is that the @ symbol is not even an extended ASCII character, so I wonder why it would have been encoded in another charset other than ASCII.

Can anyone explain what's going on? If the Android 2.3 device is actually using another encoding , is there any way to force it to ASCII before sending the SMS?

The function that sends the commands is as follows:

@Override
public void sendCommand(String command) {
    SmsManager sms=SmsManager.getDefault();
    PendingIntent piSent=PendingIntent.getBroadcast(this, 0,
                                       new Intent("SMS_SENT"), 0);
    PendingIntent piDelivered=PendingIntent.getBroadcast(this, 0,
                                            new Intent("SMS_DELIVERED"), 0);
    String phone = txtPhone.getText().toString();
    sms.sendTextMessage(phone, null, command, piSent, piDelivered);
}

Where the parameter command is always the concatenation of the prefix with some other text, like this:

String SmsPrefix = new String("A@@");
sendCommand(SmsPrefix + "AT+DEACT");
    
asked by anonymous 17.03.2014 / 18:56

1 answer

6

Answer:

The real problem is that the symbol is being "overridden" by the Operator and not by Android , you may notice testing all devices using the same carrier / SIMCard.

Previously, I found problems very similar to yours, from replacing symbols in SMS, and I discovered that my problem was with the operator.

Does this "substitution" vary from carrier to carrier and still varies from state to state ( legacy of local / minor carriers?)

Solution:

The solution I found was to find symbols that were not replaced by any of the tested operators. Unfortunately I do not remember, so I can not tell you which symbols were not replaced, but I remember that the pipe ( | ) worked well.

    
19.03.2014 / 12:14