0

我正在寻找一种方法来发送 0 类短信而不会弄乱 UCS-2 编码。

线程Class 0 SMS (flash SMS) on Android中的答案似乎与 UCS-2 编码混淆,因为正常文本可以很好地发送和接收,但需要 UCS-2 编码的语言显示为垃圾字符。

IE

发送时,http://i.stack.imgur.com/xTX8m.png

在这两种情况下,http://i.stack.imgur.com/UcYxS.png 都收到了。

两者,[线程中的第二个答案,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

而且,[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;

似乎给出了相同的结果。

关于问题出在哪里的任何想法?

4

1 回答 1

0

似乎需要 if-then 或 switch-case 语句: For 7-bit coding, as in English

利用(byte)0xF0

对于 16 位编码,UCS-2 编码

利用(byte) 0x18

否则,如果您输入不受支持的语言,则会出现垃圾字符。

于 2013-12-13T13:28:26.303 回答