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

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.

图片转代码服务由CSDN问答提供 功能建议

我使用官方的pgsqlodbc而且我有变音问题

例如:“P �edplatn�za^ ervenec 2019“

(黑色问号是错误的,正确的是”Předplatnézačervenec2019“)

但是,数据在 数据库与我的语言变音符号是正确的(我使用ODBC Devart进行测试,一切正常 - 但Devart不是免费的(我在试用时测试过)。

当我使用Valentina Studio检查数据库时 告诉我:

整理设置:编码UTF8

数据库是远程的,我只能访问 通过VPN帮助Valentina Studio和PHP。它的远程公司,我无法改变DB中的任何内容。 现在我在localhost上运行应用程序(Win10,Laragon,Wordpress,SAGE模板)。我必须使用ODBC,因为我必须连接到 远程数据库通过VPN(我使用SSH隧道帮助Putty)。但是!我写了aboce,另一个ODBC驱动程序(Devart)就是一切正常。所以,我想修复设置连接帮助免费关闭 来自Postgre的icial ODBC。

我的代码:

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

我也测试了 DRIVER = PostgreSQL ANSI(x64) - 相同的错误

  $ conn = odbc_connect($ dsn,$ user,$ password); 
 
 $ sql =“SELECT IH。  publi ..... 
 
 $ rs = odbc_exec($ conn,$ sql); 
 
 ... odbc_fetch_row($ rs)... etc. classic 
    
 
 

somobedy可以帮助我治疗错误的尿酸炎吗? 如何/在哪里可以设置UTF8编码? 我花了好几个小时才解决,没有。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongtan6543
    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"]);    
    
    点赞 评论

相关推荐