如何下载包含斯洛文尼亚特殊字符的String文件

Rak*_*esh 6 android android-networking

我正在尝试下载json包含斯洛文尼亚字符的文件,在将json文件作为字符串下载时,我将获得如下json数据中指定的特殊字符

"send_mail": "Po?lji elektronsko sporocilo.",
"str_comments_likes": "Komentarji, v?ecki in mejniki",
Run Code Online (Sandbox Code Playgroud)

我正在使用的代码

URL url = new URL(f_url[0]);
URLConnection conection = url.openConnection();
conection.connect();
try {
    InputStream input1 = new BufferedInputStream(url.openStream(), 300);
    String myData = "";
    BufferedReader r = new BufferedReader(new InputStreamReader(input1));
    StringBuilder totalValue = new StringBuilder();
    String line;
    while ((line = r.readLine()) != null) {
        totalValue.append(line).append('\n');
    }
    input1.close();
    String value = totalValue.toString();
    Log.v("To Check Problem from http paramers", value);
} catch (Exception e) {
    Log.v("Exception Character Isssue", "" + e.getMessage());
}
Run Code Online (Sandbox Code Playgroud)

我想知道如何正确下载字符.

Rak*_*esh 0

我终于找到了这种对我有用的方法

InputStream input1 = new BufferedInputStream(conection.getInputStream(), 300);

BufferedReader r = new BufferedReader(new InputStreamReader(input1, "Windows-1252"));
Run Code Online (Sandbox Code Playgroud)

我想通了windows-1252,通过将 json 文件放入 android 应用程序文件夹的 asset 文件夹中,它显示与上面指定的相同的特殊字符,它显示自动建议选项将编码更改为UTF-8, ISO-8859-1,ASCIIWindows-1252,所以我更改为windows-1252,这有效在 android studio 中,我在我们的代码中复制了相同的内容,并且有效。