Question

I develop SMS Gateway app, using GSMComm Lib. When read the message

SmsDeliverPdu data = (SmsDeliverPdu)pdu;
Output("Message: " + data.UserDataText);

it contains special character (send using autotext from BlackBerry phone) and throws An exception of type System.ArgumentException occurred and was caught

Below is the log file:

Type : System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : The value 105 is not part of the 7-bit default alphabet extension table.
Source : PDUConverter
Help link : 
ParamName : 
Data : System.Collections.ListDictionaryInternal
TargetSite : Char SevenBitExtensionToChar(Byte)
Stack Trace :    at GsmComm.PduConverter.TextDataConverter.SevenBitExtensionToChar(Byte b)
   at GsmComm.PduConverter.TextDataConverter.SevenBitToString(String s, Boolean throwExceptions)
   at GsmComm.PduConverter.PduParts.DecodeText(Byte[] userData, Byte dataCodingScheme)
   at GsmComm.PduConverter.SmsPdu.get_UserDataText()
   at GTMP.PresentationTier.Win.SMSGateway.frmSMSGateway.ShowMessage(SmsPdu pdu)
   at GTMP.PresentationTier.Win.SMSGateway.frmSMSGateway.ReadMessage()
   at GTMP.PresentationTier.Win.SMSGateway.frmSMSGateway.frmSMSGateway_Load(Object sender, EventArgs e)

How to solve this case?

Was it helpful?

Solution

Solved. I check the string contain 7bit character set or not using this regex:

"^[A-Za-z0-9 \\r\\n@£$¥èéùìòÇØøÅå\u0394_\u03A6\u0393\u039B\u03A9\u03A0\u03A8\u03A3\u0398\u039EÆæßÉ!\"#$%&'()*+,\\-./:;<=>?¡ÄÖÑܧ¿äöñüà^{}\\\\\\[~\\]|\u20AC]*$";

source

code:

public static bool IsInputContainNonGSM7BitCharacterSet(string value)
{
    string GSM_7_BIT_CHARACTER_SET = " @£$¥èéùìòÇØøÅåΔ_ΦΓΛΩΠΨΣΘΞ^{}\\[~]|€ÆæßÉ!\"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà";
    char letter = default(char);

    for (int i = 0; i < value.Length; i++)
    {
        letter = value[i];

        if (GSM_7_BIT_CHARACTER_SET.IndexOf(letter) == -1)
        {
            return true;
        }
    }
}

OTHER TIPS

Instead of using data.UserDataText, I used

TextDataConverter.SevenBitToString(TextDataConverter.OctetsToSeptetsStr((message.Data as SmsDeliverPdu).UserData), false)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top