Skip to content

Convert special characters to utf-8 #3

@sbeatrice

Description

@sbeatrice

Current Behavior

Retrieving special characters causes JSON error

Retrieving a solution from the knowledge base (manually created ontologies) that includes a two-byte special character like the german umlaut "ä" via PrologClient.cpp causes PrologBindings.cpp to throw the following error:

JSON data must be UTF-8 encoded

Cause

In PrologEngine.cpp line 95 PL_atom_chars(atom) returns the solution of the query result encoded in UTF-16 format: e.g. ä = 0x00E4.

This solution is then parsed in PrologQuery.cpp line 89 by PrologBindings::parseJSONBindings(resp.solution) which expects resp.solution to be UTF-8 encoded: e.g. ä = 0xC3 0xA4 and thus throws the JSON Error.

Storing special characters

The missing conversion between UTF-16 and UTF-8 also concerns the storage of special characters into the knowledge base. Instead of an "ä", the corresponding UTF-8 encoded characters "ä" are stored in the ontologies.

Maybe there is a different Prolog predicate instead of PL_atom_chars() that fixes this encoding problem or it could be resolved by adding a encoding conversion function to PrologEngine::run()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions