0

If the message received contains only words, there is no problem. But when the message contains emoticons plus words, the message can not be understood. I think it is in another format of some sort.

For example, if message coming from sender is "Hello" and a smiley, it will show as "00480065006C006C006F0020D83DDE00" in my C# application.

I read messages in text mode, i.e. "AT+CMGF=1". I feel that the solution is to read msgs with "AT+CMGF=0" (non text mode) to cover all types of messages, and apply an algorithm to decode. Is this the way to do it?

Most of the posts about emoticons I've come across give solutions about SENDING emoticons. I can not seem to find solutions for RECEIVING.

Vince
  • 3
  • 3

1 Answers1

0

From the text it seems to be Big Endian Unicode:

// https://stackoverflow.com/a/311179/613130
public static byte[] StringToByteArray(string hex)
{
    byte[] bytes = new byte[hex.Length / 2];

    for (int i = 0; i < hex.Length; i += 2) {
        bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
    }

    return bytes;
}

and then:

var bytes = StringToByteArray("00480065006C006C006F0020D83DDE00");
var text = Encoding.BigEndianUnicode.GetString(bytes); // Hello 
xanatos
  • 109,618
  • 12
  • 197
  • 280
  • Great :) Except for a tiny thing, on windows forms controls like richtextbox, textbox and datagridview, the output string becomes "Hello" + a square OR "Hello" + a square with a question mark inside. I tried to paste it here but it just comes up okay (Hello ). So it works inside a browser, but not completely on windows forms...Any ideas? – Vince Dec 26 '20 at 03:17
  • (I'm using Visual Studio 2019 on Win 7 Pro 64 bit) – Vince Dec 26 '20 at 03:24
  • @vincegrapes On Win10 it seems to work correctly with a simple Winforms example program: https://pasteboard.co/JGG9dEw.png . And in general it becomes a totally different question. From "decode a GSM message" to "show an emoji in Winforms on Win7" – xanatos Dec 26 '20 at 07:47
  • thanks very much, u have been so helpful :) – Vince Dec 27 '20 at 22:49