'Encoding problems in Wordpress "Title" to custom JSON

First question here.

I'm trying to make a custom API in Wordpress with register_rest_route() and some CPT (with CPT-UI Plugin). But some strange things are happening..

In the title of the post (WP Editor), if I put a "-" (hyphen) it shows — (Em-dash) in the JSON. And if I inspect the source code of the WP post it shows – (En-dash).

Example..

Title in WP Editor: "Card nº 1 - PT" [hiphen] Response in JSON: Card nº 1 — PT [it assumes a coded m-dash not an hyphen]

But if I change it to..

Title in WP Editor: "Card nº 1 _ PT" [underscore] Response in JSON: "Card nº 1 _ PT" [Ok]

It seems to be an encoding problem with En-dash.

I've changed another question related to this from here to here

Thanks for listening!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source