text-conversion-style items. Each of the text-conversion-style items would represent a particular character set that you required. For example, to facilitate the Gensym, Cyrillic, and Japanese character sets, you could create these three text conversion styles:
| Use this text-conversion-style item... | For importing and exporting... |
|---|---|
gensym-text-style
|
Gensym character set text
|
cyrillic-text-style
|
Cyrillic text
|
shift-jis-text-style
|
Japanese text
|
Once you create the text conversion styles your KB requires, any item that interacts with text conversion can use them, as described in Using a Custom Text Conversion Style.
To create a text-conversion-style item:
KB-workspace > New Definition > text-conversion-style
table.
TEXT-CONVERSION-STYLE item. Other items refer to text conversion styles by name.
External-character-set-to-use attribute lets you choose from the following character sets, where the symbol gensym is the default. The external character set determines how G2 encodes characters whenever the text conversion style is in use.
Using a Replacement Character
You can specify a replacement character to use in the event that Unicode does not have a character code for any imported character, or for any exported character that Unicode cannot represent. In the Replacement-character attribute, specify a one-character string or character code. The default is none, which means that any unrepresented characters will be omitted. Specifying the Han-Unification Mode
You can specify whether Japanese, Korean, or Chinese is preferred when translating Chinese characters into non-Unicode character sets such as gensym. Han-unification-mode attribute, choose:
japanese
chinese (traditional Chinese, simplified)
korean
japanese.
External-line-separator attribute lets you specify what characters are used to indicate the end of one text line and the beginning of the next. The
External-line-separator choice is valid only when exporting text. When importing text, G2 separates lines of text whenever it sees any of the available options. An exception is for the Unicode line separator options, which G2 only searches for when the current Text-conversion-style is using one of the Unicode character sets. Character set options are described in Determining the External Character Set to Use.
These are the six possible line separators:
While you can choose the line separator of your choice, not every option is applicable to every external character set. For example, the
unicode-line-separator or the unicode-paragraph-separator cannot be expressed in ASCII. Using a Custom Text Conversion Style
The Text-conversion-style attribute, appears in all items that interact with text conversion:
Language Parameter system table
G2-STREAM
GFI-OUTPUT-INTERFACE
When at least one text conversion style exists in a KB, you can direct any one of the previous items to use that particular style by including its name in the
Text-conversion-style attribute.
Note: Providing a named TEXT-CONVERSION-STYLE for any one of these items causes G2 to use that style for all other items that require one.
Using the Default Text Conversion Style
If you do not provide your own TEXT-CONVERSION-STYLE, and an item requires one, G2 uses a system-defined text-conversion-style. The relevant attribute values of the system-defined class are as follows:
| This attribute... | Has this value... |
|---|---|
External-character-set
|
gensym
|
Replacement-character
|
8-bit replacement char: none
|
Han-unification-mode
|
japanese
|
External-line-separator
|
per platform
|
The system-defined
text-conversion-style is generally designed to import and export text as it was done in G2 Version 4.0. For text whose external encoding was not specified in 4.0 such as Greek, Hebrew, Arabic, and Georgian, such a comparison is meaningless, but the definition of the Gensym character set clarifies the interpretation that should be assigned. japanese is used as the default Han-unification-mode is that Han (Chinese) characters are infrequently used in Korean writing, but frequently used in Japanese writing. Working with G2-Stream Objects
Several text-oriented system procedures create G2-STREAM objects as part of opening and closing files external to G2. You can specify a particular TEXT-CONVERSION-STYLE for the G2-STREAM object to use as described in Using a Custom Text Conversion Style.
Failure to specify a particular text-conversion-style causes G2 to use the system-defined style, which assumes that the external character set is Gensym.
Note: Changing the Text-conversion-style attribute while reading from or writing to a G2-STREAM causes G2 to signal an error.