douni1396 2019-08-12 08:52
浏览 220
已采纳

PHP + PostgreSQL + ODBC - UTF8 - 变音符问题

I use official pgsqlodbc and I have diacritic problem

example: "P�edplatn� za �ervenec 2019"

(black question mark is error, correct is "Předplatné za červenec 2019")

But, data in DB is correct with my language diacritics mark (I tested with ODBC Devart and everything is ok - but Devart is not free (i tested on trial).

When I check DB using Valentina Studio it tells me:

Collation Settings: Encoding UTF8

The DB is remote, I have access only via VPN with help Valentina Studio and PHP. Its remote company, i can not change anything in DB. Now I run the aplication on localhost (Win10, Laragon, Wordpress, SAGE template). I must use ODBC, because I must connect to remote DB via VPN (I use SSH tunnel with help Putty). But! I wrote aboce, with another ODBC driver (Devart) is everything OK. So, I want repair setting for connect with help free official ODBC from Postgre.

My Code:

$dsn ="DRIVER=PostgreSQL Unicode(x64);Description=Free;Data Source=localhost;Port=5433;Database=$db_customer;User ID=$user;Schema=$schema;sslmode=require;";

I tested also DRIVER=PostgreSQL ANSI(x64) - same error

$conn=odbc_connect($dsn,$user,$password);

$sql="SELECT IH.publi.....

$rs=odbc_exec($conn,$sql);

...odbc_fetch_row($rs)... etc. classic

Can somobedy help me with wrong diacritis? How/where can I set encoding UTF8? I spent hours for solving and nothing.

  • 写回答

1条回答

  • dongtan6543 2019-08-16 19:47
    关注

    Its not logic in my case(DB is not in Win1250), but its function. Diacritic is OK.

    $invoice_item["nazev"] = iconv( "CP1250", "UTF-8//IGNORE//TRANSLIT", $invoice_item["nazev"]);    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码