wp-api-v2-client-java
wp-api-v2-client-java copied to clipboard
UTF8 characters - Latin Diacritics are not rendering properly
Hi,
I checked the output of the REST API call from the browser, it is showing Latin Diacritics properly, however, the string returned from com.afrozaar.wordpress.wpapi.v2.model.Post.getContent().getRendered()
contains an invalid string with the special characters appearing as ?
.
It should be an easy fix for the author, I believe somewhere the conversion is not happening properly. I will try to fix it and submit a PR but please do check.
Update I was able to fix this. You need to slightly edit the file
com.afrozaar.wordpress.wpapi.v2.Client.java:127
Before
restTemplate = new RestTemplate(messageConverters);
After
import java.nio.charset.StandardCharsets;
....
restTemplate = new RestTemplate(messageConverters);
restTemplate.getMessageConverters()
.add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
It is a very simple change, I have never submitted a PR actually, may be the authors can fix this on their own. If a PR is required let me know, I will submit one. For now, this solves my problem.
Thanks
@michaelwiles @clintonbosch