IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
     Home      Products      Services & solutions      Support & downloads      My account     
  IBM Wikis > PHP: Zend for i5/OS > ... > 10-00-00 Chapter 10. Globalization > 10-01-00 Overview
PHP: Zend for i5/OS Log In | Sign Up   View a printable version of the current page.
10-01-00 Overview
Added by admin, last edited by admin on Mar 01, 2007  (view change)
Labels: 
(None)

Show/Hide Navigation Tree
Navigation Tree

TOC Previous Next

Overview

This section provides a brief overview of existing internationalization support in PHP 5, and then a description of each "layer" involved in providing PHP support in i5/OS and how it influences internationalization support.

PHP internationalization support

PHP 5 does not support Unicode, which makes internationalization support more complicated. According to Zend, this support will be added in the next release (PHP 6), but until then, it is necessary to find other ways to provide this functionality.

There is support for UTF-8 (see http://tools.ietf.org/html/rfc3629 for the detailed specification). You can find a good overview at http://en.wikipedia.org/wiki/Utf-8. UTF-8 support is known as CCSID 1208 on i5/OS.

To configure PHP to use UTF-8 it is necessary to modify the php.ini file (found in \usr\local\Zend\Core\etc). Edit this file and add the following line under the existing (commented out) entry:
default_charset = "UTF-8";

This should enable pages written in languages such as English, Spanish, German, or French to continue working without change.

Layers on i5/OS

Given the way PHP support is implemented on i5/OS, there are several components that "touch" the data as it is passed between the browser and the actual PHP page under execution. It is very important to understand how each of these components influences national language support.

i5/OS

Traditionally, i5/OS has always been an EBCDIC-based machine. The vast majority of applications running on the box use data that is encoded in an EBCDIC-coded character set ID (CCSID). For a list of i5/OS-supported CCSIDs, visit:
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/nls/rbagsccsidcdepgscharsets.htm)

Many CCSID transformations can and do occur automatically when running applications under i5/OS. For example, Java is a Unicode-based language. When EBCDIC data is extracted from DB2 for i5/OS via the JDBC driver, an automatic transformation occurs from EBCDIC to Unicode. Many similar such transformations occur, often unbeknownst to the application developer and user.

PHP runs in the IBM i5/OS Portable Application Solutions Environment (PASE) under i5/OS. When an i5/OS PASE shell is created from i5/OS, many globalization-related configuration settings of the i5/OS job are passed to the i5/OS PASE environment.

For a full discussion of i5/OS globalization see:
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/nls/rbagsglobalmain.htm

i5/OS PASE

The i5/OS PASE environment is an integrated runtime that makes it easy to run AIX applications from i5/OS. The following is a simplified view of how i5/OS PASE interacts with i5/OS and the System i hardware:

Figure 10-1 Simplified view of i5/OS PASE

PHP is implemented as an i5/OS PASE application that is initiated from i5/OS. Because of this, the i5/OS PASE environment that PHP runs in inherits its globalization from the i5/OS job that started it. For example, first issue the following command from i5/OS:
CHGJOB LANGID(RUS) CNTRYID(RU) CCSID(1025)

This changes the job's language and country IDs, and the job's CCSID to 1025 (which is the primary EBCDIC CCSID for Cyrillic).

Then start an i5/OS PASE terminal:
CALL PGM(QP2TERM)

As shown in Example 10-1, several globalization environment variables have been set automatically (in bold).

Example 10-1 Environment variables in new i5/OS PASE environment

$                                                                                       
 > env                                                                                     
   _=/QOpenSys/usr/bin/env                                                                 
   LANG=ru_RU                                                                              
   PASE_LANG=ru_RU                                                                         
   QIBM_PASE_DESCRIPTOR_STDIO=T                                                            
   PATH=/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin          
   ROWS=17                                                                                 
   QIBM_DESCRIPTOR_STDIN=CRLN=Y                                                            
   COLUMNS=129                                                                             
   PASE_PATH=/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin     
   LC__FASTMSG=true                                                                        
   LOGNAME=QSECOFR 
   LOCPATH=/usr/lib/nls/loc                                                                
   PASE_LC__FASTMSG=true                                                                   
   QIBM_IFS_OPEN_MAX=66000                                                                 
   QIBM_USE_DESCRIPTOR_STDIO=I                                                             
 QIBM_PASE_CCSID=915                                                                               
                     
 PASE_SHELL=/QOpenSys/usr/bin/sh                                                                   
                     
   SHELL=/QOpenSys/usr/bin/sh                                                                      
                       
   PASE_LOCPATH=/usr/lib/nls/loc                                                                   
                       
   HOME=/home/QSECOFR 
   PASE_TZ=UTC0                                                                                    
                       
   PASE_NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg
 /ru_RU/%N:/usr/lib/nls/msg/ru_RU/%N.cat 
   PWD=/                                                                                           
                       
   TZ=UTC0                                                                                         
                       
   NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg/ru_RU/%
 N:/usr/lib/nls/msg/ru_RU/%N.cat      
  $ 
                                                                                           
 ===>                                                                                      

 F3=Exit     F6=Print   F9=Retrieve   F11=Truncate/Wrap                                    
 F13=Clear   F17=Top    F18=Bottom    F21=CL command entry                                 

We see that i5/OS PASE is running with CCSID 915, which happens to be one of the main ASCII CCSIDs for Cyrillic.

For a full discussion of i5/OS PASE, see:
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rzalf/rzalfintro.htm

PHP

The most important configuration parameter from a language perspective in PHP is the default_charset directive. Some plug-ins, such as the DB2 and ODBC drivers, use the value of this directive to determine what sort of data transformation is required.

This directive can be found in the php.ini file, which by default on i5/OS is located in the /usr/local/Zend/Core/etc directory. Setting this directive causes PHP to add the configured character set to be sent down to the browser in the Content-Type header.

Apache

For the most part, no special configuration of the Apache environments is required to modify globalization settings. The HTTP servers largely act as a "pipe," passing the PHP-generated data straight through.

If you use straight HTML files in addition to PHP files, you might have to make sure that the Content-Type header is set correctly. You can do this manually by adding the code to the header section of each HTML file:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

An alternate way to accomplish this is:
<?php
header('Content-Type: text/html; charset=utf-8');
?>

Note that this configuration is for UTF-8.

Important: Make sure that your PHP file outputs the Content-Type header before any actual data intended for display is written out. In other words, you must do this within the header section and not the body.

DB2 for i5/OS

Encoding character data in DB2 can be a complex topic. As mentioned previously, depending on the way the data is encoded in DB2 for i5/OS, and what format the consuming application wants the data in, transformations can occur.

Table 10-1 shows three ways to encode Russian (Cyrillic alphabet) data in DB2 for i5/OS.

Table 10-1 Ways of encoding Russian in DB2 for i5/OS

Encoding SQL data type CCSID Description
EBCDIC CHAR/VARCHAR 1025 EBCDIC Cyrillic Multilingual
UTF-8 CHAR/VARCHAR 1208 Unicode, growing, represented as UTF-8 as defined in the Unicode Standard
Unicode GRAPHIC/VARGRAPHIC 13488 Unicode UTF-16 as defined in the Unicode Standard

We could create a single table containing columns of these data types using the DDL shown in Example 10-2.

Example 10-2 Creating table in i5/OS with three Russian character encodings

CREATE TABLE MYLIBRARY/CYRILLIC (
 EBCDIC CHAR ( 100) CCSID 1025 NOT NULL WITH DEFAULT, 
 UTF8 CHAR ( 100) CCSID 1208 , 
 UNICODE GRAPHIC (100 ) CCSID 13488 NOT NULL WITH DEFAULT) 

One way to populate the new table is by using the Operations Navigator database functions from a Windows workstation that has the Russian language installed (Control Panel > Regional and Language Options > Languages > Details... > Add).

There are two main methods of extracting data from DB2 for i5/OS into your PHP application, as detailed in Chapter 5, "Database access": using either the DB2 or the ODBC driver. As this book was being written, both of these drivers worked correctly with data encoded as detailed in Table 10-1. This occurred only after performing the configuration steps detailed in the next section.

TOC Previous Next

Top 5 contributors
to this page
UserEdits
admin 2
The postings on this site solely reflect the personal views of the authors and do not necessarily represent the views, positions, strategies or opinions of IBM or IBM management.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006)
    About IBM Privacy Contact