reading UTF-8 strings over a socket?
in
Programming Questions
•
1 year ago
Do I have to do anything special to condition a Client to receive UTF-8 strings?
When I create and display a UFT encoded string from within the app, the characters display as expected:
- String s1 = "Swifty.\u221e";
- PFont font;
- void setup() {
- size(800,800);
- background(127);
- font = loadFont("Helvetica-32.vlw");
- textFont(font);
- textAlign(CENTER);
- text(s1, width/2, height/2);
- }
..but when I read a similar string via a client connection:
- Client client = new Client(_parent, host, port);
- if (client.available() > 0) {
- inString = _client.readStringUntil('\n');
- ...
- }
... the strings are displayed with odd characters. (Disclaimer: I haven't tried too hard to trace this down -- my problem may lay elsewhere. But Client seems like the most likely culprit...)
1