91 lines
5.5 KiB
HTML
91 lines
5.5 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="Text conversion" />
|
||
|
<meta name="abstract" content="Character data is converted through the AS400Text class. This class converts character data between an EBCDIC code page and character set (CCSID), and Unicode." />
|
||
|
<meta name="description" content="Character data is converted through the AS400Text class. This class converts character data between an EBCDIC code page and character set (CCSID), and Unicode." />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="dtadtext" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Text conversion</title>
|
||
|
</head>
|
||
|
<body id="dtadtext"><a name="dtadtext"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Text conversion</h1>
|
||
|
<div><p>Character data is converted through the AS400Text class. This class
|
||
|
converts character data between an EBCDIC code page and character set (CCSID),
|
||
|
and Unicode. </p>
|
||
|
<div class="section"><p><a href="javadoc/com/ibm/as400/access/AS400Text.html#NAVBAR_TOP"> AS400Text</a></p>
|
||
|
<p>When the AS400Text object is <a href="javadoc/com/ibm/as400/access/AS400Text.html#CONSTRUCTOR_DETAIL"> constructed</a>,
|
||
|
the Java™ program
|
||
|
specifies the length of the string to be converted and the server CCSID or
|
||
|
encoding. The CCSID of the Java program is assumed to be 13488 Unicode.
|
||
|
The <a href="javadoc/com/ibm/as400/access/AS400Text.html#TOBYTES(JAVA.LANG.OBJECT)"> toBytes()</a> method converts from Java form
|
||
|
to byte array in iSeries™ format.
|
||
|
The <a href="javadoc/com/ibm/as400/access/AS400Text.html#TOOBJECT(BYTE[])"> toObject()</a> method converts from a byte array in iSeries format
|
||
|
to Java format. </p>
|
||
|
<p>The <a href="javadoc/com/ibm/as400/access/AS400BidiTransform.html#NAVBAR_TOP"> AS400BidiTransform</a> class provides layout transformations
|
||
|
that allow the conversion of bidirectional text in iSeries format (after its conversion
|
||
|
to Unicode) to bidirectional text in Java format, or from Java format
|
||
|
to iSeries
|
||
|
format. The default conversion is based on the CCSID of the job. To alter
|
||
|
the direction and shaping of the text, specify a <a href="javadoc/com/ibm/as400/access/BidiStringType.html#NAVBAR_TOP"> BidiStringType</a>. Note that where IBM<sup>®</sup> Toolbox for Java objects perform the conversion internally,
|
||
|
as in the DataArea class, the objects have a method to override the string
|
||
|
type. For example, the DataArea class has addVetoableChangeListener() method
|
||
|
that you can specify to listen for a veto changes to certain properties,
|
||
|
including string type.</p>
|
||
|
</div>
|
||
|
<div class="section"><h4 class="sectiontitle">Example: Converting text data</h4><p>The following example
|
||
|
assumes that a DataQueueEntry object returns text in EBCDIC. The example converts
|
||
|
the EBCDIC data to Unicode, so that the Java program can use data:</p>
|
||
|
<pre> // Assume the data queue work has already been done to
|
||
|
// retrieve the text from the iSeries and the data has been
|
||
|
// put in the following buffer.
|
||
|
int textLength = 100;
|
||
|
byte[] data = new byte[textLength];
|
||
|
|
||
|
// Create a converter for the iSeries data type. Note a default
|
||
|
// converter is being built. This converter assumes the iSeries
|
||
|
// EBCDIC code page matches the client's locale. If this is not
|
||
|
// true the Java program can explicitly specify the EBCDIC
|
||
|
// CCSID to use. However, it is recommended that you specify a
|
||
|
// CCSID whenever possible (see the Notes: below).
|
||
|
AS400Text textConverter = new AS400Text(textLength)
|
||
|
|
||
|
// Note: Optionally, you can create a converter for a specific
|
||
|
// CCSID. Use an AS400 object in case the program is running
|
||
|
// as an IBM Toolbox for Java proxy client.
|
||
|
int ccsid = 37;
|
||
|
AS400 system = ...; // AS400 object
|
||
|
AS400Text textConverter = new AS400Text(textLength, ccsid, system);
|
||
|
|
||
|
// Note: You can also create a converter with just the AS400 object.
|
||
|
// This converter assumes the iSeries code page matches
|
||
|
// the CCSID returned by the AS400 object.
|
||
|
AS400Text textConverter = new AS400Text(textLength, system);
|
||
|
|
||
|
// Convert the data from EBCDIC to Unicode. If the length of
|
||
|
// the AS400Text object is longer than the number of
|
||
|
// converted characters, the resulting String will be
|
||
|
// blank-padded out to the specified length.
|
||
|
String javaText = (String) textConverter.toObject(data);</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|