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"]);    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料