Skip to content

get_chars method fails to decode UTF-8 bytes packed into integer #49

@stancld

Description

@stancld

PDFium's FPDFText_GetUnicode returns unsigned 32-bit integer. Integers ≤ 1114111 are valid Unicode codepoint and can be converted with python in-built chr function. Larger integers are UTF-8 bytes packed into integers and must be handled separately.

Example

parsed pypdfium in UTF-8 int as: 15112101.

Current behavior

>>> chr(15112101)
ValueError: chr() arg not in range(0x110000)

Expected behavior

>>> utf8_int_to_string(15112101)
'日'

Suggestion

I will send a fix shortly.

Metadata

Metadata

Assignees

No one assigned

    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