android - 使用 json 的泰卢固语文本

标签 android json translation android-fonts

是否可以从服务器检索用泰卢固语编写的文本以供应用程序使用。我为 Json 使用了以下格式。它在 avd 的 logcat 中给了我一些符号错误。如果不是,哪个适合获取此类文本。

{
"contacts": [
    {
            "id": "c200",
            "name": "అశ్విని",
            "email": "అశ్విని@అశ్విని.అశ్విని",
            "address": "అశ్విని",
            "gender" : "అశ్విని",
            "phone": {
                "mobile": "అశ్విని",
                "home": "అశ్విని",
                "office": " రేవతి"
            }
    },
    {
            "id": "c201",
            "name": "అశ్విని ram",
            "email": "అశ్విని@అశ్విని.అశ్విని",
            "address": "అశ్విని",
            "gender" : "అశ్విని",
            "phone": {
                "mobile": "అశ్విని",
                "home": "అశ్విని",
                "office": "అశ్విని"
            }
    }
]
} 

下面是我用来获取数据的代码

public class JSONParser {

static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

// constructor
public JSONParser() {

}

public JSONObject getJSONFromUrl(String url) {

    // Making HTTP request
    try {
        // defaultHttpClient
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        is = httpEntity.getContent();           

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        is.close();
        json = sb.toString();
    } catch (Exception e) {
        Log.e("Buffer Error", "Error converting result " + e.toString());
    }

    // try parse the string to a JSON object
    try {
        jObj = new JSONObject(json);
    } catch (JSONException e) {
        Log.e("JSON Parser", "Error parsing data " + e.toString());
    }

    // return JSON String
    return jObj;

}
}

最佳答案

您需要在 Assets 文件夹中使用 NTR.TTF 字体,并且应更改以下行

BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8000);

关于android - 使用 json 的泰卢固语文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13158052/

相关文章:

android - 从 ViewHolder onclick 开始 Activity

c++ - Jsonxx - 迭代 Json

nlp - 将自然语言转换为俳句?

java应用程序有像android一样的翻译文件

Java:将 XML 映射到其他 XML(翻译)

android - android文件夹(bin、xbin、sbin)之间的区别

android - fragment 是否可以扩展 fragment ?

android - 如何在运行时获取准确的ListView高度?

mysql - 从 MySQL JSON 列中提取 JSON 对象的值作为数组

json - 使用python将json和文件发送到flask