Note that there are some explanatory texts on larger screens.

plurals
  1. PORead/write .txt file with special characters
    primarykey
    data
    text
    <p>I open <strong>Notepad</strong> (Windows) and write</p> <pre><code>Some lines with special characters Special: Žđšćč </code></pre> <p>and go to <strong>Save As...</strong> "someFile.txt" with <strong>Encoding</strong> set to <strong>UTF-8</strong>.</p> <p>In Java I have</p> <pre><code>FileInputStream fis = new FileInputStream(new File("someFile.txt")); InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); BufferedReader in = new BufferedReader(isr); String line; while((line = in.readLine()) != null) { printLine(line); } in.close(); </code></pre> <p>But I get question marks and similar "special" characters. Why?</p> <p><strong>EDIT:</strong> I have this input (one line in .txt file)</p> <pre><code>665,Žđšćč </code></pre> <p>and this code</p> <pre><code>FileInputStream fis = new FileInputStream(new File(fileName)); InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); BufferedReader in = new BufferedReader(isr); String line; while((line = in.readLine()) != null) { Toast.makeText(mContext, line, Toast.LENGTH_LONG).show(); Pattern p = Pattern.compile(","); String[] article = p.split(line); Toast.makeText(mContext, article[0], Toast.LENGTH_LONG).show(); Toast.makeText(mContext, Integer.parseInt(article[0]), Toast.LENGTH_LONG).show(); } in.close(); </code></pre> <p>And <strong>Toast</strong> output (for ones who aren't familiar with Android, Toast is just a method to show a pop-up on screen with particular text in it) is fine. Console shows "weird characters" (probably because of encoding in console window). But it fails at parsing an integer because console says this (<code>warning: toast output is just fine</code>) - <a href="http://slike.hr/slike/snag0022_f3402.jpg.html" rel="nofollow">Problem</a>?</p> <p>It seems like the String is containing some "weird" characters which Toast can't show/render but when I try to parse it, it crashes. Suggestions?</p> <p>If I put ANSI in NotePad it works (integer parsing) and there are no weird chars as in the picture above, but of course my special characters aren't working.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload