UTF-8 (Chinese) in servoy REST Webservice
Posted: Sun Dec 30, 2018 4:12 pm
Hi,
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 羅莎大)
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 羅莎大.
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.
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 羅莎大)
- Code: Select all
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 羅莎大.
- Code: Select all
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.