A question pertaining to this topic was posted in another forum. I have
included the answer here for those who have to deal with this issue.

Unlike MS SQL Server 7.0/2000, MS Access 2000 does not use separate types
for non-UNICODE and UNICODE text data. Instead, ALL text data is stored as
UNICODE. In other words, MS Access 2000 no longer has non-UNICODE text
data types. The problem is that the MS Access ODBC driver externally
indcates that they are non-UNICODE. And, the only way to submit queries
containing UNICODE data is with the UNICODE version of the ODBC API.

The only PHP solution that provides access to the UNICODE ODBC API is
ODBTP. To process UNICODE data via PHP/odbtp you must do the following:

1. Include the following HTML meta tag within the HTML head section in
EVERY PHP script and HTML file containing a form that calls a PHP script.

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

2. After connecting to the database with odbtp_connect(), enable UNICODE
SQL support using odbtp_set_attr():

$con = odbtp_connect(...);
odbtp_set_attr( ODB_ATTR_UNICODESQL, TRUE, $con );

3. Rebind all fields bound as ODB_CHAR to ODB_WCHAR after running a query:

$qry = odbtp_query( "SELECT ... FROM ..." );

$cols = odbtp_num_fields( $qry );

for( $col = 0; $col < $cols; $col++ ) {
    if( odbtp_field_bindtype( $qry, $col ) == ODB_CHAR )
        odbtp_bind_field( $qry, $col, ODB_WCHAR );

Note: All UNICODE text data is read and sent by the ODBTP server using
UTF-8 encoding and not UCS-2, including query text strings.

Now that I am aware of what MS Access is doing, I will make this a little
easier to do in the next version of ODBTP.

BTW:  Users of MS SQL Server do not have to rebind any fields. The SQL
Server ODBC driver properly indicates which text fields are UNICODE.

-- bob

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to