Forum Stats

  • 3,875,253 Users
  • 2,266,901 Discussions
  • 7,912,124 Comments

Discussions

Trouble with UTF-8 and PHP-OCI

1053685
1053685 Member Posts: 19
edited Jul 15, 2014 2:26PM in PHP

Hi there!

I'm having some serious trouble with UTF-8. I just tried to insert a lambda into an NCLOB column in one of my databases and it was converted to an inverted question mark. I have verified that the string reaches my PHP script correctly encoded. Also selecting RAWTOHEX(column) in SQL Developer shows, that the inverted question mark is already stored in the column. So the problem must be somewhere between PHP-OCI and the database. Inserting a lambda via SQL developer works. I can also correctly fetch it via PHP.

I'm using the latest PHP-OCI (2.0.8). v$version says "Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production".

The database is fairly old and uses WE8MSWIN1252 as the character set and AL16UTF16 as the NCHAR character set. Hence I'm using NCLOB instead of CLOB. However, I connect to the database with AL32UTF8, since my app is running in UTF-8. I was under the impression that this would result in an automatic conversion from UTF-8 to UTF-16 when inserting into NCLOB columns, but apperently this is not the case. It looks like there is some sort of double conversion, first UTF-8 to WE8MSWIN1252 and then to UTF-16, because some non-ASCII characters like ä (a umlaut) get correctly converted from UTF-8 to UTF-16.

Any ideas? I'm at a loss here. Thanks in advance.

Best Answer

Answers

This discussion has been closed.