PDU & UDH Trouble

Any one with experience on this ?
I’ve manage to built pdu’s but due to unicode use we need more characters for the sms’s. The solution was to use multi part PDU’s.

I’ve manage to get something with my older code.

For the multi part sms is the code between /////////////////// UDH

I’m dividing that sentence in 3 ways, below is the result of the decode to text.

The information contained herein is subject to change without notice. Revisions may be issued to advice of such changes and/or additions.

PDU - 079153916209508141000C915391413316060008AA32DA0D350303A1030100540068006500200069006e0066006f0072006d006100740069006f006e00200063006f006e007400610069006e00650064002000680065007200650069006e0020006900730020007300750062006a00650063007400200074006f0020006300680061006e0067006500200077006900740068006f0075

Decoded PDU - ��㔃Ρ́The information contained herein is subject to

PDU - 079153916209508141000C915391413316060008AA32DA0D350303A103020020006e006f0074006900630065002e00200020005200650076006900730069006f006e00730020006d00610079002000620065002000690073007300750065006400200074006f00200061006400760069006300650020006f0066002000730075006300680020006300680061006e0067006500730020

Decoded PDU - ��㔃Ρ̂ notice. Revisions may be issued to advice of

PDU - 079153916209508141000C915391413316060008AAB718350303A10303006e0064002f006f00720020006100640064006900740069006f006e0073002e

Decoded PDU - ᠵ̃ꄃ̀渀搀⼀漀爀 愀搀搀椀琀椀漀渀猀⸀

The first 2 are not bad but i cant have the first characters, the third one is a mess !

Anyone that can help me ??

public static string GetPdu(string number, string message, string smscAddress, bool multi, int total, out int actualLength)
{

        if (multi == true)
        {
            smsCount++;
        }
        const byte internationalFormat = 0x91; // telephone/ISDN, international format
        const byte unknownFormat = 0x81; // telephone/ISDN, unknown format

        // Determine destination address type
        byte numberAddressType;
        string useNumber;
        if (number.StartsWith("+"))
        {
            numberAddressType = internationalFormat;
            useNumber = number.Substring(1); // strip initial "+" character
        }
        else
        {
            numberAddressType = unknownFormat;
            useNumber = number;
        }

        // Determine SMSC address type
        byte smscAddressType;
        string useSmscAddress;
        if (smscAddress.StartsWith("+"))
        {
            smscAddressType = internationalFormat;
            useSmscAddress = smscAddress.Substring(1); // strip initial "+" character
        }
        else
        {
            smscAddressType = unknownFormat;
            useSmscAddress = smscAddress;
        }

        // Encode the user data text
        byte dataLength;
        // byte[] encodedText = EncodeText(message, out dataLength);
        string encodedText = EncodeText2(message, out dataLength);
        //byte[] encoded8bit = Encode8bitText(message, out dataLength);
        // Encode the SMSC address
        string encodedSmsc = EncodeSmscAddress(useSmscAddress, smscAddressType);

        // Create the PDU string
        StringBuilder builder = new StringBuilder();
        builder.Append(IntToHex(0x41)); // message flags:
        //   msg type=SMS-SUBMIT-PDU,
        //   validity=relative
        builder.Append(IntToHex(0x00)); // Message Reference, 0=set by device
        builder.Append(EncodeDestinationAddress(useNumber, numberAddressType));
  
        builder.Append(IntToHex(0x00)); // Protocol ID, 0=SME-to-SME
        builder.Append(IntToHex(0x08)); // Data Coding Scheme, 0=7-Bit default
        builder.Append(IntToHex(0xAA)); // Relative Validity, 0xA7=24 hrs,0xAA=4days
        /////////////////// UDH
        int dlINT = ((dataLength*2) + 2 + 5);
        byte[] dlBYTE = SeptetsToOctetsInt(dlINT.ToString());
        foreach (byte b in dlBYTE)
        { 
        builder.Append(IntToHex(b)); // Data Lenght (UDHL + UDH + TEXT)
        }
        builder.Append(IntToHex(SeptetsToOctetsInt("5")));//User Header Data Lenght - UHDL (UDH LENGHT)
        //UDH
        builder.Append(IntToHex(0x03)); // Identifier
        builder.Append(IntToHex(0x03)); // Information Element Data Lenght
        builder.Append(IntToHex(0xA1)); // Ref num
        builder.Append(IntToHex((byte)total)); // Total
        builder.Append(IntToHex((byte)smsCount)); // This Part
        //UDH
        ////////////////// UDH
        builder.Append(encodedText);
        //builder.Append(IntToHex(encoded8bit)); 

         actualLength = builder.Length / 2;
         builder.Insert(0, encodedSmsc);
         builder.Insert(builder.Length, "_");
         builder.Insert(builder.Length, actualLength);
         return builder.ToString();
    
    }