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

Asked

Viewed 1,089 times

16

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 sent some "commands" for an Android phone 4.3 and for an Android 2.3.

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

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

The function that sends commands is the following:

@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 prefix concatenation with some other text, so:

String SmsPrefix = new String("A@@");
sendCommand(SmsPrefix + "AT+DEACT");
  • I’m pretty sure you can solve this just by using sendMultipartTextMessage() instead of sendTextMessage() Just come on out and tell me if it worked

  • @Pauloroberto, thanks for the tip... I really read in some reply in the OS that this would be possible, but I just tested and stayed in the same :/ No Android 4.3 continues coming A¿¿

  • 1

    Have you tested all devices with the same carrier/Simcard? I found very similar problems of replacing symbols in SMS and at the end my problem was in the operator.

  • Well observed @molusco, Android 2.3 was with TIM chip and iPhone too.. Android 4.3 was Vivo. I’ll try switching the chips tomorrow to see what happens.

  • @mollusk, you hit the nail on the head. Any SMS sent from TIM at least to Claro arrives with the ¿ in place of @. The Android version doesn’t really matter a bit. Prepare the answer there that this is yours! hehe..

1 answer

6


Answer:

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

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

This "replacement" is something that varies from operator to operator and still varies from state to state (something legacy of local/smaller operators?)

Solution:

The solution I found was to find symbols that were not replaced by any of the operators tested. Unfortunately I don’t remember, so I can’t tell you which symbols were not replaced, but I remember that the "pipe" (|) had good results.

  • Yeah. in my case I’m now using * in place of @ and it’s going well. Thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.