Java Android如何向PHP发送带有重音符号的文本

Java Android如何向PHP发送带有重音符号的文本,java,android,diacritics,Java,Android,Diacritics,我的应用程序有一个问题,当我试图向我的apache服务器发送一个包含像mámémímómú这样的字符的文本时,它将字符作为m?发送?。我怎样才能解决这个问题 这是我的代码: public boolean loginstatus(String reporte, String user) { File file = new File(fileUri.getPath()); try { MultipartEntityB

我的应用程序有一个问题,当我试图向我的apache服务器发送一个包含像mámémímómú这样的字符的文本时,它将字符作为m?发送?。我怎样才能解决这个问题

这是我的代码:

public boolean loginstatus(String reporte, String user) {
            File file = new File(fileUri.getPath());
            try {
                  MultipartEntityBuilder entity = MultipartEntityBuilder.create();
                  Log.e("enviando", "archivo "+fileUri.getPath());
                  Log.e("enviando", "reporte "+reporte);
                  Log.e("enviando", "usuario "+user);
                  entity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
                  entity.addTextBody("reporte", reporte);
                  entity.addTextBody("usuarioID",user);
                  if (file.length() <= 0){
                  }else{
                  entity.addPart("archivo", new FileBody(file));
                  }
                  final HttpEntity yourEntity = entity.build();
                  httppost.setEntity(yourEntity);
                  HttpResponse response = httpclient.execute(httppost);
                } catch (ClientProtocolException e) {
                     e.printStackTrace();
                } catch (IOException e) {
                     e.printStackTrace();
                }
            return true;

        }
public boolean loginstatus(字符串报告,字符串用户){
File File=新文件(fileUri.getPath());
试一试{
MultipartEntityBuilder实体=MultipartEntityBuilder.create();
Log.e(“enviando”、“archivo”+fileUri.getPath());
Log.e(“环境”、“报告”+报告);
Log.e(“enviando”、“usuario”+用户);
entity.setMode(HttpMultipartMode.BROWSER_兼容);
实体。addTextBody(“报告”,报告);
entity.addTextBody(“usuarioID”,用户);

如果(file.length()首先,这里的问题是编码。 数据库的表未编码为使用UTF-8,或者发送的字符串不是UTF-8

表问题:

您可以在db表上使用字符集utf8

字符串问题: 解决这个问题的优雅方法是使用

StringEntity实体=新的StringEntity(您的文本,“UTF-8”);


另一种方法是使用字符串的
getBytes(“UTF-8”)
函数并使用DataOutputStream

谢谢,但是该放在哪里呢?再次感谢。你把特殊字符放在哪里了。我猜是:entity.addTextBody(“report”,report);应该是:entity.addTextBody(urlcoder.encode(“reporte mámémímúm”,“UTF-8”),report);我发现使用URLEncoder更容易。