INSERT INTO words (word, meaning) VALUES ('Цветок', 'Flower')
When I execute this SQL statement from an SQL client (DbVisualizer), the values in the table look exactly like you see them here in the statement, i.e. Цветок
is not encoded.
When I execute it from PHP over Tomcat 8 / Java version "1.8.0_101" (Quercus 4.0.39) , the values in the table are encoded exactly as if I would run the PHP urlencode() on them. So Flower
is not changed, but Цветок
is - now it looks in the table through the SQL client like ЦвеÑок
Why is there difference between running the SQL statement from the client or from PHP?
How can I insert this data from PHP so that it will be saved in the database unchanged?
UPDATE
Here is my Tomcat context.xml HSQLDB Resource:
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="me" password="kjsfhsjhfsd" driverClassName="org.hsqldb.jdbc.JDBCDriver"
url="jdbc:hsqldb:hsql://localhost:9001/mydb?characterEncoding=UTF-8"/>
The characterEncoding=UTF-8
is actually MySql specific (so having it breaks this resource!). What is the HSQLDB equivalent? I could not find...
I also tried to set the php.ini
with unicode.semantics=on
as explained here:
http://www.caucho.com/resin-3.1/doc/quercus.xtp#php.ini
http://www.caucho.com/resin-3.1/doc/quercus.xtp#Internationalization-16-bitunicode
http://www.caucho.com/resin-3.1/doc/quercus.xtp#encoding
However, it did not make any change...