Reading and writing unicode strings
in
Programming Questions
•
3 years ago
I want to read from a text file that includes some typical german characters, then display that text. Putting literal text in the sketch works fine, but when reading from the file, it looks like loadStrings() isn't reconstructing the UTF-8 characters. I guess I can do that manually by inspecting each byte, but is there a better way?
- PFont f = createFont("Ariel-Black", 32, true);
size(400,400);
fill(0);
textFont(f);
// test 1: works
text("sie müßte", 50, 50);
// test 2: doesn't work
// file contains "sie müßte"
String [] lines = loadStrings("sample.txt");
text(lines[0], 50, 100);
println(lines[0]);
1