2017-01-13 20:23
浏览 283

PHP ODBC连接到Oracle,没有UTF-8

I am having a problem to get UTF-8 support, when i try to connect to Oracle throught ODBC Data Source with PHP odbc_connect().

Also all of this is being done under 32bits. I am using oracle XE DB for testing and instaclient11_2 32bit drivers, ODBC Data source 32it +placed on WAMP32bit server.

Althougt i have same result with Oracle 12c DB and client Home 10g 32bit drivers.

@TODAY Tested this all with 64bit instanclient drivers, added ODBC 64DataSource on 64bit WAMP Server. Still no luck to display chars corretly...

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

$connect = odbc_connect("XEXDB", "username", "password");

$query = "SELECT col, 'čaļi' FROM TESST";

$result = odbc_exec($connect, $query);

  $name = odbc_result($result, 1);
  $surname = odbc_result($result, 2);
  echo "$name, $surname <br/>";



Result i get from this code:

?A?IS, A?aA?i 
Gunt?rs Salts, A?aA?i 

But should be:

ĶAĶIS, čaļi
Guntārs Šalts, čaļi

I cant find how to write $dsn for odbc_connect() to force charset=utf-8, so far no luck to get working $conn_string with charset=utf-8.

Also tried to use utf8_encode() and utf8_decode()(using this was me being desperate).

Does anyone have had similar problem, or maybe someone have some suggestions i could try?

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

当我尝试通过ODBC数据源连接到Oracle时,我遇到了获得UTF-8支持的问题 PHP odbc_connect()

所有这些都是在32位下完成的。 我正在使用oracle XE DB进行测试和instaclient11_2 32位驱动程序,ODBC数据源32it +放置在WAMP32bit服务器上。

Althougt我对Oracle 12c DB和客户端Home 10g 32位驱动程序有相同的结果。

@TODAY使用64位instanclient驱动程序测试了这一切,在64位WAMP服务器上添加了ODBC 64DataSource。 仍然没有运气正确显示字符...

 &lt; html&gt; 
&lt; head&gt; 
&lt; meta http-equiv =“Content-Type”content =“  text / html; charset = utf-8“/&gt; 
&lt; / head&gt; 
&lt; body&gt; 
 $ connect = odbc_connect(”XEXDB“,”username“,”password“)  ; 
 $ query =“SELECT col,'čaļi'INTERTESST”; 
 $ result = odbc_exec($ connect,$ query); 
while(odbc_fetch_row($ result)){
 $  name = odbc_result($ result,1); 
 $ surname = odbc_result($ result,2); 
 echo“$ name,$ surname&lt; br /&gt;”; 
odbc_close($ connect  ); 


Gunt?rs Salts,A?aA?i 

但是应该 be:


我无法找到如何编写 odbc_connect()的$ dsn 强制 charset = utf-8 ,到目前为止没有运气与#code> charset = utf-8一起工作$ conn_string

还尝试使用 utf8_encode() utf8_decode()(使用这个让我感到绝望)。

有没有人有过类似的问题,或者有人 有一些我可以尝试的建议吗?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题