I’m trying to get chinese working in the REST service and I hope someone can point me in the right direction.
Inside of Servoy it is all working correctly, but when it exits servoy and we look in a sniffer and at the client, the texts is wrong.
What I have so far. (when I check _result, it is still 羅莎大)
var bytes = _result.getBytes("UTF-8");
return bytes;
Before I had only .getBytes() → this resulted in ??? instead of 羅莎大.
When we added .getBytes(“UTF-8”) → it became 羅莎大. Which is the ANSI encoding.
Other actions we have tried: changed the server.xml of tomcat/apache and added URIEncoding=“UTF-8” to the connector, but that also doesn’t work. Still 羅莎大.
Also I made a test c# client, which ads UTF8 to the request, but it still returns 羅莎大.
HttpResponseMessage response = await client.PostAsync(targetUrl, new StringContent(requestData, Encoding.UTF8, "application/json"));
HttpContent content = response.Content;
var byteArray = await content.ReadAsByteArrayAsync();
var result = Encoding.UTF8.GetString(byteArray, 0, byteArray.Length);
Is there anyone who knows in which direction we can further look?
It feels like I’m missing something in servoy or in apache/tomcat.
To be honest, I don’t know why it returns bytes. The project was developed by another developer and transferred to me.
But the difference I notice when I remove the .getBytes() is that the json that is returned isn’t valid.
For example without the .getBytes it is:
/"property/"=10
Instead of
"property"=10
But the content type of the response is application/json;charset=UTF-8.
So I’m starting to think, I’m doing something strange somewhere. As it all seems to be correct.
Thanks Robert!
It did gave me the idea, to build up a object in code to return immediatly, instead of building the json object in a string.
That has solved the problem.
This project was still on servoy 6.x though, so it was a bit of a search, because JSON.stringify came available later. But luckily I found the answer on this forum to, to use json2 stringify.