It's the umlauts again. Can't sent UTF-8 strings over network. Please help!
in
Core Library Questions
•
2 years ago
Using the alternet library for networking I can't sent a string from client to server or vice versa if the string contains special characters such as umlauts. There are a number of places that suggest converting the string to a byte array and then converting back to a string afterwards. I have tried to find examples of this but I can't seem to find any that work for me.
In my client I have
String sometext = "some string";
try
{
byte[] lineData = wholeLine.getBytes("UTF-8");
}
catch (UnsupportedEncodingException e)
{
println(e.getMessage());
}
client.send(lineData);
But it never sends as it doesn't seem to recognise the ("UTF-8") section of the code. When I remove the catch() it always says UnsupportedEncodingException.
How can I convert a UTF8 string to byte array and send to the server?
How does it get reconverted afterwards?
The server will sent to all the clients afterwards so I presume it gets reconverted when returned to the clients.
I'm struggling with this one. Anyone?
In my client I have
String sometext = "some string";
try
{
byte[] lineData = wholeLine.getBytes("UTF-8");
}
catch (UnsupportedEncodingException e)
{
println(e.getMessage());
}
client.send(lineData);
But it never sends as it doesn't seem to recognise the ("UTF-8") section of the code. When I remove the catch() it always says UnsupportedEncodingException.
How can I convert a UTF8 string to byte array and send to the server?
How does it get reconverted afterwards?
The server will sent to all the clients afterwards so I presume it gets reconverted when returned to the clients.
I'm struggling with this one. Anyone?
1