Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert special characters to utf-8 #3

Open
sbeatrice opened this issue Apr 18, 2020 · 0 comments
Open

Convert special characters to utf-8 #3

sbeatrice opened this issue Apr 18, 2020 · 0 comments

Comments

@sbeatrice
Copy link

sbeatrice commented Apr 18, 2020

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()?

daniel86 added a commit that referenced this issue Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant