
Code Conversion Algorithms
|
581
Converting ISO-2022 to EUC is a simple matter of using the following two assignment
statements in C:
p1 += 128;
p2 += 128;
ese assignment statements have an eect of adding 128 (8) to the current values of
the variables p1 and p2. ese statements could also have been written as follows:
p1 = p1 + 128;
p2 = p2 + 128;
Both styles perform the same task. C (and other programming languages) has a shorthand
method for doing these sort of variable assignments. ere are even shorthand methods
for turning the eighth bit on or o.
Next, converting EUC to ISO-2022 requires the following two statements (or their
equivalent):
p1 -= 128;
p2 -= 128;
ese assignment statements have an eect of subtracting 128 (8) from the current
value of the variables p1 and p2. at’s really all there is to do.
One dicult issue to contend with is how to handle half-width katakana, which can be
represented in EUC-JP encoding using code set 2, but have no ocial representation in
ISO-2022-JP encoding. I suggest that they be converted into their full-width counterparts
(see the section later in this chapter entitled “Half- to Full-Width Katakana Conversion—
in Java”).
Conversion Between ISO-2022 and Row-Cell
Conversion from ISO-2022 to Row-Cell is a matter of subtracting 32 (2) from each
of the ISO-2022 bytes.
*
Similarly, conversion from Row-Cell to ISO-2022 is a matter of
adding ...