Skip to content

Encoding errors caused by emoticons and emoji characters, such as 🌸🌸🌸, etc. #120

@zwc456baby

Description

@zwc456baby

I tried to send an emoji and got an encoding error. After checking, I found that it was a compatibility error in the PDU encoding method. This is the code I fixed. I used AI to provide me with a compatible code. I'm not sure if there are other unknown errors.

def encodeUcs2(text):
    """ UCS2 text encoding algorithm

    Encodes the specified text string into UCS2-encoded bytes.

    :param text: the text string to encode

    :return: A bytearray containing the string encoded in UCS2 encoding
    :rtype: bytearray
    """
    # result = bytearray()

    # for b in map(ord, text):
    #     result.append(b >> 8)
    #     result.append(b & 0xFF)
    # return result

    return bytearray(text.encode('utf-16-be'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions