doumingchen3628 2019-02-02 17:42
浏览 67
已采纳

从android应用程序到PHP脚本的重音登录字符串

I'm developping an Android application. This app has to connect to a server with login and password. This launches a PHP script on the remote server which then get the login and password strings. When I use a character such "é" in the login (which is possible), the PHP script get the character "�".

How to get the correct character in my PHP script ? Thanks.

  • 写回答

1条回答 默认 最新

  • dsqpx86002 2019-02-02 18:13
    关注

    You can convert the character to UTF-8 using mb_convert_encoding() in PHP

    // PHP
    $enc = mb_convert_encoding("é", "UTF-8");
    echo $enc;
    

    Set charset=UTF-8 in your Android application HTTP client as well.

    // JAVA
    byte[] bytes = "é".getBytes("UTF-8"); 
    String body = new String(bytes, Charset.forName("UTF-8"));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失