Skip to content

Hyphenation does not not work with 1.2.x #102

@Jaizkibel

Description

@Jaizkibel

After switching to 1.2.2, the hyphenation does not work anymore.

The reason seems to be the UniversalDetector class which does not recognize the encoding of the XML files from the itext-hyph_xml.jar

Code snippet from class SimpleXMLParser:

public static void parse(SimpleXMLDocHandler doc, InputStream in) throws IOException {
        byte b4[] = new byte[4];
        int count = in.read(b4);
        if (count != 4)
            throw new IOException(MessageLocalization.getComposedMessage("insufficient.length"));
        UniversalDetector detector = new UniversalDetector(null);
        detector.handleData(b4, 0, count);
        String encoding = detector.getDetectedCharset();     // <--- returns null

        String decl = null;
        if (encoding.equals("UTF-8")) {    // <--- NPE
            ...

so the XML is not parsed and the hyphenation not done, because the HyphenationTree is empty

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