Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you have <code>byte[]</code> or an <code>InputStream</code> (both binary data) you can get a <code>String</code> or a <code>Reader</code> (both text) with:</p> <pre><code>final String encoding = "UTF-8"; // "UTF16LE" or "UTF-16BE" byte[] b = ...; String s = new String(b, encoding); InputStream is = ...; BufferedReader reader = new BufferedReader(new InputStreamReader(is, encoding)); for (;;) { String line = reader.readLine(); } </code></pre> <p>The reverse process uses:</p> <pre><code>byte[] b = s.geBytes(encoding); OutputStream os = ...; BufferedWriter writer = new BufferedWriter(new OuputStreamWriter(os, encoding)); writer.println(s); </code></pre> <p>Unicode is a numbering system for all characters. The UTF variants implement Unicode as bytes.</p> <hr> <p><em><strong>Your problem:</em></strong></p> <p>In normal ways (web service), you would already have received a <code>String</code>. You could write that string to a file using the Writer above for instance. Either to check it yourself with a <strong>full Unicode font</strong>, or to pass the file on for a check.</p> <p>You need (?) to check, which UTF variant the text is in. For Asiatic scripts UTF-16 (little endian or big endian) are optimal. In XML it would be defined already.</p> <hr> <p><em><strong>Addition:</em></strong></p> <p><a href="http://docs.oracle.com/javase/7/docs/api/java/io/FileWriter.html" rel="nofollow">FileWriter</a> writes to a file using the default encoding (from operating system on your machine). Instead use:</p> <pre><code>new OutputStreamWriter(new FileOutputStream(new File("...")), "UTF-8") </code></pre> <p>If it is a binary PDF, as @bobince said, use just a FileOutputStream on byte[] or InputStream.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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