I am looking for a way to send class 0 sms without messing with UCS-2 encoding.
The answers in the thread Class 0 SMS (flash SMS) on Android, seem to be messing with UCS-2 encoding, as normal text is sent and received well, but languages that require UCS-2 encoding appears as junk characters.
I.E.
When sending,
In both cases, is received.
Both, [ Second Answer in thread, stackoverflow.com/a/9424185/3082310 ]
byte[] encodedMessage = pdus.encodedMessage;
// byte[0] = mtiByte
// byte[1] = TP Message Reference
// byte[2] = length of source phone
// byte[3..length] = phone
// protocol identifier
int msgLen = encodedMessage[2] / 2;
// +2 -> length of source phone
// +2 -> for 91 after the length
// +1 -> TP PID
int indexTPDCS = msgLen + 5;
byte TPDCS = encodedMessage[indexTPDCS];
byte[] changedMessage = encodedMessage.clone();
// Set bit 4 to 1 using OR (|), indicating there is a message class
// Set bit 0 and 1 to 0 using AND (&), indicating class 0
byte newTPDCS = (byte) ((TPDCS | 0x10) & 0xFC); // Flash SMS
changedMessage[indexTPDCS] = newTPDCS; // Class 0
And, [ ZeroSMS, github.com/virtualabs/ZeroSMS ]
/* change class to Class 0 *
int size;
size = (int)pdus.encodedMessage[2];
size = (size/2) + (size%2);
pdus.encodedMessage[size+5] = (byte)0xF0;
Seem to give the same results.
Any ideas on where the problem lies?
It seems there is a need for if-then or switch-case statements: For 7-bit coding, as in english
use (byte)0xF0
For 16-bit encoding, UCS-2 encoding
use (byte) 0x18
Otherwise, junk characters appear if you enter unsupported language.