|
wb_script_encoding | Auxiliary Functions | wb_escape_string |
A SQL server accepts the text of SQL statements in the encoding specified upon its creation. This encoding may differ from the encoding of the PHP script, therefore the national characters in SQL statements may get corrupted.
Incorrect interpretation may also occur for national characters getting out of the database, because the PHP script is written in another encoding.
The wb_set_script_encoding function therefore:
If the PHP script encoding is different than WB_ENC_UNKNOWN, then the following conversions are done:
From the PHP script encoding into the database system encoding:
From the database system encoding into the PHP script encoding
When reading values of the CHAR(n) or CLOB types using the wb_result and wb_fetch_into functions, that value will be converted into the PHP script encoding. BEWARE: Unicode strings/CLOBs will ALWAYS be read in the UTF-8 encoding!!!
When reading the values of OUT and INOUT parameters of the CHAR(n) nd CLOB types in SQL statement executed by the wb_exec and wb_psql_execute functions, the values will be converted into the PHP script encoding. UNICODE values are always converted into the UTF-8 encoding. The output values of string OUT and INOUT parameters read by the wb_psql_get_out_param function are converted in the same way.
Output values if client variables of the CHAR(n) and CLOB types that are passed to the wb_import_from_XML and wb_export_to_XML and wb_import_from_XML_buffer and wb_export_to_XML_buffer functions will be converted into the PHP script encoding. The output UNICODE parameter values are always converted into UTF-8.
Supported charsets:
TRUE if successful, FALSE otherwise.
Display contents of a SELECT, that has differently encoded columns, in UTF-8.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>attempt</title></head> <body> <h1>Text with national characters may be here if the file is stored in the UTF-8 coding)</h1> <? wb_set_script_encoding(WB_ENC_UTF8); $dsn = "sql95test"; $appl = "_all_tests"; $dbuser = ""; $conn=wb_connect($dsn, $appl, $dbuser); $cursor=wb_exec($conn, "select * from Addresses"); while (wb_fetch_into($cursor, $buff)) { for ($i=1; $i<=wb_num_fields($cursor);$i++){ echo wb_field_name($cursor, $i).": $buff[$i]<br>"; } echo "<br>"; } ?> </body> </html>
wb_script_encoding | Auxiliary Functions | wb_escape_string |