How to send special chars(Extended Charset)?

Smpp v3.4 client

Moderator: alt

Locked
okmenn
Posts: 2
Joined: Fri Jul 24, 2009 12:17 pm

How to send special chars(Extended Charset)?

Post by okmenn » Fri Oct 30, 2009 3:00 pm

I need to send extended chars as | ^ € { } [ ~ ] \ without using unicode because when I use unicode message maxlength becomes much shorter than initial 160 chars, so one message is splitted in two or more messages, and that has a cost.

Is there any solution?

Thank you a lot.
BenEllis
Posts: 21
Joined: Mon Nov 09, 2009 4:30 pm
Location: Leicester, United Kingdom
Contact:

GSM 03.38 / ASCII Encoder

Post by BenEllis » Wed Nov 11, 2009 12:56 pm

Use the below function to generate your ShortMessageBytes and change the DataEncoding to ASCII (GSM03.38).

i.e. req.ShortMessageBytes = GSMEncode("!£$%^&*()€");

public static byte[] GSMEncode(string PlainText)
{
// ` is not a conversion, just a untranslatable letter.
// x0D should be CR but this causes double linefeed on
// some phones so has been removed.
const string strGSMTable =
"@£$¥èéùìòÇ\nØø`Åå" +
"Δ_ΦΓΛΩΠΨΣΘΞ`ÆæßÉ" +
" !\"#¤%&'()*+,-./" +
"0123456789:;<=>?" +
"¡ABCDEFGHIJKLMNO" +
"PQRSTUVWXYZÄÖÑÜ`" +
"¿abcdefghijklmno" +
"pqrstuvwxyzäöñüà";

const string strExtendedTable =
"````````````````" +
"````^```````````" +
"````````{}`````\\" +
"````````````[~]`" +
"|```````````````" +
"````````````````" +
"`````€``````````" +
"````````````````";

using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
foreach (char cPlainText in PlainText.ToCharArray())
{
if (cPlainText != '`') // Ignore `
{
int intGSMTable = strGSMTable.IndexOf(cPlainText);
if (intGSMTable != -1)
{
ms.WriteByte((byte)intGSMTable);
continue;
}
int intExtendedTable = strExtendedTable.IndexOf(cPlainText);
if (intExtendedTable != -1)
{
ms.WriteByte(27);
ms.WriteByte((byte)intExtendedTable);
}
}
}

ms.Close();
return ms.ToArray();
}
}
Locked