4

I have UTF-8 file and I want to print its content, so I tried:

println new File("C://Problem_1.txt").getText("UTF-8")

But the result is:

я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜ я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜

How to solve this problem?

Xelian
  • 16,680
  • 25
  • 99
  • 152
  • How did you ensure the text you saved is in UTF-8 and correct? – blackdrag Jul 25 '14 at 13:15
  • Could you please first the encoding is utf8? println new InputStreamReader(new FileInputStream(new File("C://Problem_1.txt"))).encoding – Fran García Jul 25 '14 at 14:22
  • I do what mr Garcia said and the output is UTF8. I open the file with Notepad++ and change the encoding to UTF-8 and then UTF-8 without BOM but nothing happens. The UFT-8 character are not shown properly – Xelian Jul 25 '14 at 14:58
  • 1
    Does your output display support UTF-8? If you're using Windows command prompt, take a look at this: http://stackoverflow.com/questions/1259084/what-encoding-code-page-is-cmd-exe-using – bdkosher Jul 25 '14 at 15:18
  • OK in the matter of fact I don't want to print it, I want to use this value in I method. I don't see UTF-8 on console I wrote chcp 1252. But again nothing. I want to use the file content in ByteArrayOutputStream out = QRCode.from(it.getText("utf-8")) .to(ImageType.PNG).withCharset("utf-8").stream(); Where "it" is the file. If the console is broken Ok. But why can't pass it on the method? If I pass UTF-8 literals every thing is OK the problem is when read from the file. – Xelian Jul 25 '14 at 17:36
  • Dont use unicode with images/bin files, you should use base64 encoding – Wajdy Essam Jul 27 '14 at 11:58

0 Answers0