drmg17928 2017-03-13 10:22
浏览 52
已采纳

Php问题与人物

I am building an app with Apache cordova for the support team for my company and everything was ok when I was using a test database in UTF8 was working.

Then when I was implement the real db I notice it was encoded with win-1252.

The problem is, even the db is with win-1252 we have many rows using special caracters like "ç" and "~" and "´" and "`" and with that when I am running the php all rows in the tables in my db will not show becasue of that.

Keep in mind I cann't convert the db to utf8.

ps:The solution I see is go to each row and remove that caracters but isn't a good solution(about 20,000 rows)

........................

PHP file:

header("Access-Control-Allow-Origin: *");

$dbconn = pg_connect("host=localhost dbname=bdgestclientes2 
    user=postgres password=postgres") 
    or die('Could not connect: ' . pg_last_error());

$data=array();

$q=pg_query($dbconn,"SELECT * FROM clientes WHERE idcliente = 3");

$row=pg_fetch_object($q)){$data[]=$row};

echo json_encode($data);

  • 写回答

3条回答 默认 最新

  • douweihui0178 2017-03-13 12:46
    关注

    I just needed to add a line in php to encode to unicode so I could use the data and display the way it is

    pg_set_client_encoding($dbconn, "UNICODE");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题