This project is read-only.

Cyrillic symbols encoding support

Jul 9, 2013 at 4:35 PM
Hi all (sorry for my English)
I need to send sms messages with cyrillic symbols. Can you tell me, does jamaa library support that symbols type? If it does, help me please with that programmatically encoding, Thank you!
Jun 25, 2015 at 8:09 AM
Hello, join to Jukka3d question/

Tnks
Jun 25, 2015 at 12:04 PM
Edited Jun 25, 2015 at 1:46 PM
extented method to add cyrillic and fix a bug vDefaultReverseTable[index] = (byte)vDefaultForwardTable[index];
    private static void BuildTable()
    {
        //Please note that, charactors from 0x10 to 0x1B are not supported by this implementation
        //Instead, they are converted to a space charactor (0x20)
       vDefaultForwardTable = new char[]
        {
         /*    0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,  8 , 9 , 10 , 11, 12, 13, 14, 15 */
            /*0*/' ','☺','☻','♥','♦','♣','♠','•', '◘','○','◙', '♂','♀','♪', '♫','☼',
            /*1*/'►','◄','↕','‼','¶','§','▬','↨', '↑','↓','→', '←','∟','↔', '▲','▼',
            /*2*/' ','!','"','#','$','%','&','\'','(',')','*', '+',',','-', '.','/',
            /*3*/'0','1','2','3','4','5','6','7', '8','9',':', ';','<','=', '>','?',
            /*4*/'@','A','B','C','D','E','F','G', 'H','I','J', 'K','L','M', 'N','O',
            /*5*/'P','Q','R','S','T','U','V','W', 'X','Y','Z', '[','\\',']', '^','_',
            /*6*/'`','a','b','c','d','e','f','g', 'h','i','j', 'k','l','m', 'n','o',
            /*7*/'p','q','r','s','t','u','v','w', 'x','y','z', '{','|','}', '~','⌂',
            /*8*/'А','Б','В','Г','Д','Е','Ж','З', 'И','Й','К', 'Л','М','Н', 'О','П',
            /*9*/'Р','С','Т','У','Ф','Х','Ц','Ч', 'Ш','Щ','Ъ', 'Ы','Ь','Э', 'Ю','Я',
           /*10*/'а','б','в','г','д','е','ж','з', 'и','й','к', 'л','м','н', 'о','п',

           /*11*/'░','▒','▓','│','┤','╡','╢','╖','╕', '╣','║','╗', '╝','╜', '╛','┐',

           /*11*/'└','┴','┬','├','─','┼','╞','╟','╚', '╔','╩','╦', '╠','═', '╬','╧',
           /*12*/'╨','╤','╥','╙','╘','╒','╓','╫','╪', '┘','┌','█', '▄','▌', '▐','▀',
           /*13*/'р','с','т','у','ф','х','ц','ч','ш', 'щ','ъ','ы', 'ь','э', 'ю','я',
           /*14*/'Ё','ё','Є','є','Ї','ї','Ў','ў','°', '∙','·','√', '№','¤', '■'
        };



        //This table is used for reverse lookup
        vDefaultReverseTable = new byte[byte.MaxValue];
        string chars = new string(vDefaultForwardTable, 0, vDefaultForwardTable.Length);
        int index = 0;
        for (; index < byte.MaxValue; ++index)
        {
            vDefaultReverseTable[index] = 128;
        }

        for (index = 0; index < vDefaultForwardTable.Length; ++index)
        {
            vDefaultReverseTable[index] = (byte)vDefaultForwardTable[index];
        }
    }
But I don't see russian symbols in sms, why? Please help me.
Jun 25, 2015 at 12:09 PM
Edited Jun 25, 2015 at 1:46 PM
extented method to add cyrillic and fix a bug vDefaultReverseTable[index] = (byte)vDefaultForwardTable[index];
    private static void BuildTable()
    {
        //Please note that, charactors from 0x10 to 0x1B are not supported by this implementation
        //Instead, they are converted to a space charactor (0x20)
       vDefaultForwardTable = new char[]
        {
            /*    0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,  8 , 9 , 10 , 11, 12, 13, 14, 15 */
            /*0*/' ','☺','☻','♥','♦','♣','♠','•', '◘','○','◙', '♂','♀','♪', '♫','☼',
            /*1*/'►','◄','↕','‼','¶','§','▬','↨', '↑','↓','→', '←','∟','↔', '▲','▼',
            /*2*/' ','!','"','#','$','%','&','\'','(',')','*', '+',',','-', '.','/',
            /*3*/'0','1','2','3','4','5','6','7', '8','9',':', ';','<','=', '>','?',
            /*4*/'@','A','B','C','D','E','F','G', 'H','I','J', 'K','L','M', 'N','O',
            /*5*/'P','Q','R','S','T','U','V','W', 'X','Y','Z', '[','\\',']', '^','_',
            /*6*/'`','a','b','c','d','e','f','g', 'h','i','j', 'k','l','m', 'n','o',
            /*7*/'p','q','r','s','t','u','v','w', 'x','y','z', '{','|','}', '~','⌂',
            /*8*/'А','Б','В','Г','Д','Е','Ж','З', 'И','Й','К', 'Л','М','Н', 'О','П',
            /*9*/'Р','С','Т','У','Ф','Х','Ц','Ч', 'Ш','Щ','Ъ', 'Ы','Ь','Э', 'Ю','Я',
           /*10*/'а','б','в','г','д','е','ж','з', 'и','й','к', 'л','м','н', 'о','п',

           /*11*/'░','▒','▓','│','┤','╡','╢','╖','╕', '╣','║','╗', '╝','╜', '╛','┐',

           /*11*/'└','┴','┬','├','─','┼','╞','╟','╚', '╔','╩','╦', '╠','═', '╬','╧',
           /*12*/'╨','╤','╥','╙','╘','╒','╓','╫','╪', '┘','┌','█', '▄','▌', '▐','▀',
           /*13*/'р','с','т','у','ф','х','ц','ч','ш', 'щ','ъ','ы', 'ь','э', 'ю','я',
           /*14*/'Ё','ё','Є','є','Ї','ї','Ў','ў','°', '∙','·','√', '№','¤', '■'
        };

        //This table is used for reverse lookup
        vDefaultReverseTable = new byte[byte.MaxValue];
        string chars = new string(vDefaultForwardTable, 0, vDefaultForwardTable.Length);
        int index = 0;
        for (; index < byte.MaxValue; ++index)
        {
            vDefaultReverseTable[index] = 128;
        }

        for (index = 0; index < vDefaultForwardTable.Length; ++index)
        {
            vDefaultReverseTable[index] = (byte)vDefaultForwardTable[index];
        }
    }
But I don't see russian symbols in sms, why? Please help me.
Jun 25, 2015 at 12:12 PM
my method to send sms
            mmSubmitSm = new SubmitSm(); // init the submitsm method
            //Populate SubmitSm properties as required
            mmSubmitSm.SourceAddress.Address = "3143"; // source sender
            mmSubmitSm.SourceAddress.Ton = TypeOfNumber.Aphanumeric; // source TON
            mmSubmitSm.SourceAddress.Npi = NumberingPlanIndicator.Unknown; // source NPI

            mmSubmitSm.DestinationAddress.Address = "9819283923"; // destination MSISDN
            mmSubmitSm.DestinationAddress.Ton = TypeOfNumber.International; // destionation TON
            mmSubmitSm.DestinationAddress.Npi = NumberingPlanIndicator.ISDN; // destionation NPI 

            mmSubmitSm.EsmClass = EsmClass.Default; // esm class
            mmSubmitSm.DataCoding = DataCoding.Cyrillic;
            //mmSubmitSm.RegisteredDelivery = RegisteredDelivery.DeliveryReceipt; //reg_del to 1
            mmSubmitSm.ServiceType = ""; // service type cellular messaging, - not mandatory to set, you can leave it
            mmSubmitSm.SetMessageText("#3 ПРИВЕТ МИР", DataCoding.SMSCDefault); // send msg - all OK, message receiv

            mmSubmitSmResp = mmSession.SendPdu(mmSubmitSm) as SubmitSmResp; // send PDU
With english all ok, with russian no.
Jun 25, 2015 at 2:56 PM
Edited Jun 25, 2015 at 3:00 PM
Also I extended methods in SMPPEncodingUtil.cs for converting message from string to byte and byte to string
        switch (dataCoding)
        {
          //.......
         case DataCoding.Cyrillic:
                bytes = System.Text.Encoding.GetEncoding(1251).GetBytes(cStr);
                break;
        default:
                throw new SmppException(SmppErrorCode.ESME_RUNKNOWNERR, "Unsupported encoding");
        }

        switch (dataCoding)
        {
          //.......
         case DataCoding.Cyrillic:
                result = System.Text.Encoding.GetEncoding(1251).GetString(data);
                break;
         default:
                throw new SmppException(SmppErrorCode.ESME_RUNKNOWNERR, "Unsupported encoding");
          }
and change method for sending sms messages
        mmSubmitSm.SetMessageText("#3 ПРИВЕТ МИР", DataCoding.Cyrillic); // send msg - all OK, message receiv

        mmSubmitSmResp = mmSession.SendPdu(mmSubmitSm) as SubmitSmResp; // send PDU
and nothing happend, I got empty sms.
Feb 14 at 9:02 AM
Jukka3d you can don't extented method to add cyrillic and fix a bug vDefaultReverseTable[index] = (byte)vDefaultForwardTable[index];

At the file SMPPEncodingUtil.cs just resplace strings
case DataCoding.UCS2:
                bytes = System.Text.Encoding.Unicode.....
to
case DataCoding.UCS2:
                bytes = System.Text.Encoding.BigEndianUnicode...
Use USC2 codepage