Skip to content

Sending big russian text makes message improperly encoded #53

@SuperMasterBlasterLaser

Description

Hello.

I have service which sends SMS messages and will accept parameters via SMPP

I'm using this lines of code to send message:

    parts, encoding_flag, msg_type_flag = smpplib.gsm.make_parts(text)

    client = smpplib.client.Client(sms_host, sms_port)

    client.set_message_sent_handler(
        lambda pdu: sys.stdout.write('sent {} {}\n'.format(pdu.sequence, pdu.message_id)))
    client.set_message_received_handler(
        lambda pdu: sys.stdout.write('delivered {}\n'.format(pdu.receipted_message_id)))

    client.connect()
    client.bind_transceiver(system_id=system_id, password=password)

    for part in parts:
        pdu = client.send_message(
            source_addr_ton=5,
            source_addr_npi=0,
            # Make sure it is a byte string, not unicode:
            source_addr=source_addr,

            dest_addr_ton=1,
            dest_addr_npi=1,
            # Make sure thease two params are byte strings, not unicode:
            destination_addr=dest_addr,
            short_message=part,

            data_coding=encoding_flag,
            esm_class=msg_type_flag,
            registered_delivery=True,
        )

When I try to send russian or any cyrrillic text, SMS service sends me that kind of text:

Привеееет привввввееееееееет прип�䀄㠄㼄䀄㠄㈄㈄㈄㈄㈄㈄㈄㔄㔄㔄㔄㔄㔄䈄䈄䈄䈄䈄䰄䰄䰄䰀 䴄䈄㸀 㐄�лгий дооолги и оченнь доооолги  т�㔄㔄㔄㨄䄄䈀 㐄㬄伀 㼄䀄㸄㈄㔄䀄㨄㠀 㼄䀄㸄㈄㔄䀄㨄  䄄㠄䄄䈄�мы система вклбченр вы йцк   нужн�  㨄㬄〄㈄  㤄䘄䌄㨄㔄�

The interesting thing is that some parts are correct and some parts become weird chineese symbols.

Why this is happening?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions