如何将utf-8字符串发送到服务器并保存。当发送此字符串时例如在数据库保存(DD)中发送(لل)时请帮帮我吗?
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("Content-Type", "application/json; charset=utf-8");
params.put("body", edt_body.getText().toString());
params.put("en_body", edt_en_body.getText().toString());
params.put("title", edt_title.getText().toString());
params.put("en_title", edt_en_title.getText().toString());
params.put("mobile_id", DatabaseOpenHelper.mobile_id);
params.put("key", DatabaseOpenHelper.key);
return params;
}
答案 0 :(得分:1)
使用
替换类中的一些代码private void buildTextPart(DataOutputStream dataOutputStream, String parameterName, String parameterValue) throws IOException {
dataOutputStream.writeBytes(twoHyphens + boundary + lineEnd);
dataOutputStream.writeBytes("Content-Disposition: form-data; name=\"");
dataOutputStream.write(parameterName.getBytes("UTF-8"));
dataOutputStream.writeBytes(lineEnd);
dataOutputStream.writeBytes("Content-Type: text/plain; charset=UTF-8" + lineEnd);
dataOutputStream.writeBytes(lineEnd);
dataOutputStream.write(parameterValue.getBytes("UTF-8"));
dataOutputStream.writeBytes(lineEnd);
}
现在正确的工作