On character sets and encodings

Background

A frequent topic in the SMS world concerns character sets and their encodings. This topic is non-trivial, so here we’ll try to clarify things as much as possible. We’ll discuss character sets, character encodings, and a bit on how EMG handles these things.

Character sets

First, we have character sets. These are the things that says that the character “A” should be represented by the numeric value 65. However, the value used for a specific character differs between character sets. For example, in the character set Latin-1, the “at sign” character, “@”, has the value 64, and in GSM-7 it has the value 0. To send a “@”, you must therefore not only send either the value 0 or 64, you must also tell the recipient which character set it should use to figure out which character you are referring to.

For SMS, there are two particularly important character sets, GSM-7 and Unicode. GSM-7 works fine for languages using the latin based alphabets, while Unicode also covers most of the rest of the alphabets.

GSM-7

GSM-7 is a 7 bit character set, using the values between 0 and 127. Many of the values are identical to the ones in the ASCII set, where 65 means “A”, etc. The values below 32 are mostly Greek characters. Among the differences between GSM-7 and Latin-1 (discussed below) we can mention the value 64, which means “¡” in GSM-7, and “@” in Latin-1.

The special value 27 is used to say that the next byte should be interpreted according to a secondary table with 128 characters. There is a main secondary table which contains characters such as “{” and “}”, and a handful of additional tables containing various (accented) characters specific for certain languages. For example, there is a special secondary table for Portuguese and one for Turkish. Despite its popularity for slavic languages, there is, as of 2026, still no secondary table defined for the cyrillic alphabet.

Unicode

Basically everything on internet encodes characters using the Unicode set. Most characters there have a value below 65536, which means the values need 16 bits. Emojis and some other characters have values above this. No character needs more than 32 bits, though.

Latin-1

The Latin-1 set, which is more properly called ISO 8859-1, is basically the first 256 characters of Unicode. There is also a handful of other ISO 8859 variants, but the differences between them are small. We have no records of any SMSC using any other variant than “1”.

Encodings

Next, we come to character encodings. Here we have things like “one byte per character” (hereafter referred to as OneByte), UCS-2, and UTF-8.

One Byte Per Character

For character sets where all values are below 256, we can use the OneByte encoding. This therefore works fine for both GSM-7 and Latin-1. However, we still need to know which character set is being used, for example if we see the value 64. Otherwise we don’t know whether the sender meant “¡” or “@”.

UCS-2

UCS-2 is popular among the SMS protocols for encoding character values above 255. It is indicated there by setting data_coding=8. UCS-2 uses two bytes per character, with the high byte first.

UTF-8

The most common encoding used when communicating between systems is UTF-8. Internal storage is a different matter, but web pages and emails are almost always in UTF-8. For character values below 128, one byte is used. For values up to 16383, two bytes are used. Even larger values simply use more bytes. This makes it compact and human readable for European languages, while still being able to encode the rest of the Unicode set.

There is nothing that says that UTF-8 can only be used for the Unicode set, so you can encode any other character set using the same mechanism. You can even encode any type of integer value this way, in order to minimize the space used. In practice however, in our context, we can assume that the values refer to Unicode characters.

UTF-16

A more recent addition is UTF-16, which is basically a conceptual combination of UCS-2 and UTF-8. SMS operators don’t support UTF-8, and UCS-2 doesn’t work for values above 65535. So, in order to send emojis, we use UTF-16. For values up to 65535, it looks the same as with UCS-2. However, there is a small value range in the Unicode set which isn’t used by any characters. If such a value is found, we combine the offset within that range with the next 16 bits. For older systems, this means the byte sequence used for an emoji will be interpreted as two strange characters, but everything else will be correct.

EMG support

As of version 7.2.25, EMG handles all of this automatically. However, the sender must tell EMG which character set is being used.

Some operators only support GSM-7 as the OneByte encoding, and some only Latin-1. Regardless of how the message was received, EMG can then recode the message automatically as needed.

As of version 8.1.0, EMG supports the national language tables for Portuguese and Turkish. We still have not found any operators that actually support them properly, and even less so for the rest of these tables.

Fonts

As the final step, each character value is then displayed based on some font. Not all fonts contain the appearance of every Unicode and GSM-7 character value, so even if the handset ends up getting the intended character value, it may still be displayed incorrectly. This is, obviously, outside of EMG’s control.