Android 将表情符号转换为unicode

Android 将表情符号转换为unicode,android,json,unicode,emoji,Android,Json,Unicode,Emoji,我需要发送一个包含文本以及表情符号的文本到服务器。我使用jsonparser类将其发送到服务器,但当我发送时,服务器端似乎包含unicode的问号instaed。我应该如何继续转换到unicode。请帮忙 List<NameValuePair> params = new ArrayList<NameValuePair>(); Log.d("userstatus",userstatus); params.add(new Basi

我需要发送一个包含文本以及表情符号的文本到服务器。我使用jsonparser类将其发送到服务器,但当我发送时,服务器端似乎包含unicode的问号instaed。我应该如何继续转换到unicode。请帮忙

    List<NameValuePair> params = new ArrayList<NameValuePair>();

         Log.d("userstatus",userstatus);

        params.add(new BasicNameValuePair("my_status",userstatus));
         params.add(new BasicNameValuePair("user_id",userid));



          try{
              // getting JSON string from URL
               JSONObject json3 = jParser.makeHttpRequest(url_updateprofilestatus, "POST", params);

                 Log.d("json response: ", json3.toString());
                 JSONObject response=json3.getJSONObject("response"); 
List params=new ArrayList();
Log.d(“userstatus”,userstatus);
添加(新的BasicNameValuePair(“我的状态”,用户状态));
添加(新的BasicNameValuePair(“用户id”,userid));
试一试{
//从URL获取JSON字符串
JSONObject json3=jParser.makeHttpRequest(url_updateprofilestatus,“POST”,params);
d(“json响应:,json3.toString());
JSONObject response=json3.getJSONObject(“response”);
我的JSONParser类

public class JSONParser {

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

// constructor
public JSONParser() {

}

// function get json from url
// by making HTTP POST or GET mehtod
public JSONObject makeHttpRequest(String url, String method,
        List<NameValuePair> params) {

    // Making HTTP request
    try {

        // check for request method
        if(method == "POST"){
            // request method is POST
            // defaultHttpClient
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost(url);
            httpPost.setEntity(new UrlEncodedFormEntity(params));

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

        }else if(method == "GET"){
            // request method is GET
            DefaultHttpClient httpClient = new DefaultHttpClient();
            String paramString = URLEncodedUtils.format(params, "utf-8");
            url += "?" + paramString;
            HttpGet httpGet = new HttpGet(url);

            HttpResponse httpResponse = httpClient.execute(httpGet);
            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;

}
公共类JSONParser{
静态InputStream为空;
静态JSONObject jObj=null;
静态字符串json=“”;
//建造师
公共JSONParser(){
}
//函数从url获取json
//通过使用HTTP POST或GET方法
公共JSONObject makeHttpRequest(字符串url、字符串方法、,
列表参数){
//发出HTTP请求
试一试{
//检查请求方法
如果(方法==“POST”){
//请求方法为POST
//defaultHttpClient
DefaultHttpClient httpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(url);
setEntity(新的UrlEncodedFormEntity(参数));
HttpResponse HttpResponse=httpClient.execute(httpPost);
HttpEntity HttpEntity=httpResponse.getEntity();
is=httpEntity.getContent();
}else if(方法==“GET”){
//请求方法是GET
DefaultHttpClient httpClient=新的DefaultHttpClient();
String paramString=URLEncodedUtils.format(params,“utf-8”);
url+=“?”+参数字符串;
HttpGet HttpGet=新的HttpGet(url);
HttpResponse HttpResponse=httpClient.execute(httpGet);
HttpEntity HttpEntity=httpResponse.getEntity();
is=httpEntity.getContent();
}          
}捕获(不支持的编码异常e){
e、 printStackTrace();
}捕获(客户端协议例外e){
e、 printStackTrace();
}捕获(IOE异常){
e、 printStackTrace();
}
试一试{
BufferedReader reader=新的BufferedReader(新的InputStreamReader(
is,“iso-8859-1”),8);
StringBuilder sb=新的StringBuilder();
字符串行=null;
而((line=reader.readLine())!=null){
sb.追加(第+行“\n”);
}
is.close();
json=sb.toString();
}捕获(例外e){
Log.e(“缓冲区错误”,“错误转换结果”+e.toString());
}
//尝试将字符串解析为JSON对象
试一试{
jObj=新的JSONObject(json);
}捕获(JSONException e){
Log.e(“JSON解析器”,“错误解析数据”+e.toString());
}
//返回JSON字符串
返回jObj;
}
}


我用文本和表情符号的“?”得到响应。请帮助。

我得到了答案。要获得表情符号的unicode码:

StringEscapeUtils.escapeJava(<text>); 
StringEscapeUtils.unescapeJava(<unicode_emoticon>);
StringEscapeUtils.escapeJava();
并将其解码回表情符号:

StringEscapeUtils.escapeJava(<text>); 
StringEscapeUtils.unescapeJava(<unicode_emoticon>);
StringEscapeUtils.unescapeJava();

这是API标准吗