Loading...
Logo
Processing Forum
Hello Guys

Does the LoadStrings fuction can load characters outside basic utf-8? i would like to pick up french characters like "é" "è" "à" "ù" etc...

I will try to see with a php method because i don't suppose it's possible to adapt loadStrings(). 
Share me your suggestions

Cheers

Replies(5)

I suggest you make a text file, then use loadStrings and see what happens. You can post the result here.
as i thought loadStrings() just allowed chars contained in utf-8. 

Anyway, i can use others language that allowed regex like php.

Thx for your suggest amnon !


ok i was wrong you just need to use a file saved in UTF8 and not use an ANSI encode.
Ok for a txt file but with an url i can't read theses kind of char in the strings



String[] web = loadStrings("http://www.le-dictionnaire.com/definition.php?mot=bonjour");


String joined = join(web,"");


String r = joined.replaceAll("<(.*?)>", "");


println(r);


/////////// All non english chars are replaced by "?"
Yes, you have to use a bit more black magic...
Copy code
  1. import java.io.*;
  2.  
  3. InputStream input = createInput("http://www.le-dictionnaire.com/definition.php?mot=bonjour");
  4. BufferedReader reader = null;
  5. try
  6. {
  7.   reader = new BufferedReader(new InputStreamReader(input, "ISO-8859-1")); // loadStrings() does that with "UTF-8"
  8. }
  9. catch (IOException e)
  10. {
  11.   e.printStackTrace();
  12.   exit();
  13. }
  14. String[] web = loadStrings(reader);
  15. String joined = join(web, "");
  16. String r = joined.replaceAll("<(.*?)>", "");
  17. println(r);