Output Character Set for Text Display/Download



To display text properly when viewing or downloading spooled files as text, the PUIWRKSPLF utility needs to let the HTTP server know how the text is encoded. The utility can not always detect the file encoding automatically. By default, the PUIWRKSPLF uses the CPYSPLF command to convert spooled files to text. The CPYSPLF command can choose different encodings for the output file, depending on the spooled file attributes. CPYSPLF sets the output file CCSID to 65535, so the actual encoding used is unknown. Also, spooled files can be converted to text via custom logic run from the exit program.

By default, PUIWRKSPLF assumes text files are encoded in UTF-8. If your text files are created with a different encoding, the output will not display properly. To customize the output character set, you can set the environment variable PUI_WRKSPLF_CHARSET either in the HTTP server configuration, or via custom logic in the PUISPLEXIT exit program.

Examples

To set the variable in the HTTP server configuration, edit the HTTP server configuration file at /www/INSTANCE_NAME/conf/httpd.conf. The default instance name is PROFOUNDUI, but can be customized at installation time. The configuration directive should be added to the global area of the configuration file – outside of any <Directory>, <Files>, <VirtualHost>, or other blocks.

# Set output text encoding to Big5 for Traditional Chinese. SetEnv PUI_WRKSPLF_CHARSET big-5

If custom logic is needed to set the encoding differently depending on the particular file, RPG code like this can be used in the exit program:

d putenv pr 10i 0 extproc('putenv') d string * value options(*string) /free if timingFlag = 0; // Before download. // Default to UTF-8. putenv('PUI_WRKSPLF_CHARSET=utf-8'); // Run some logic here to determine if another encoding is used. // Maybe by looking at spooled file name, or other attributes. if spoolId.SplfName = 'EXAMPLE'; // Set to Big-5 for Traditional Chinese. putenv('PUI_WRKSPLF_CHARSET=big-5'); endif; endif; howHandled = 1; return; /end-free