buzza

Android and windows-1251 ?

A lot of russian sites are based on windows-1251, but sqlite uses UTF-8 and UTF-16. So, if you won’t prepare your data for android – all cyrillic symbols will be broken.

How to deal with it?
For the most part of java programmers who familiar with java.io – this issue is well known.
We just need to specify encoding type of our data to

public static String inputStreamToString(final InputStream stream) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(stream, "windows-1251"));
StringBuilder sb = new StringBuilder();
        String line;
        while ((line = br.readLine()) != null) {
            sb.append(line);
            sb.append("n");
        }
        br.close();
        return sb.toString();
    }
Add Comment Register

Leave a Reply


3 + seven =