3 - 43 3 - 43
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
(5) Processes using full-byte characters
As shown in Section 3.13.1, one full-byte character (Kanji) uses the amount of
space required for two half-byte characters both for display and storage. For this
reason, the following consideration must be taken when handling a character
string containing full-byte characters in half-byte character increments.
1) When using a function that extracts a portion of a character string
The character length of a character string that contains full-byte characters is
as follows.
The KLEN function is
used when full-byte
characters are to be
treated as one
character.
For details,
see Section 3.13.3.
1 2 3 45 67 89 1011 12 13 14
OK
PRINT LEN( "A B C
D E F" )
@ @ @ @
14
OK
As shown in the example above, full-byte characters are counted as two
characters. When full-byte characters as contained in the character string in
which LEFT$, MID$, or RIGHT$ is to be used, full-byte characters must be
treated as two characters. The screen display will contain errors if one half of a
full-byte character is extracted.
OK
PRINT LE FT$ ("
ABC@@
OK
PRINT LEFT$("
ABC@
OK
PRINT RIGHT$("
d@ DEF
OK
1 2 3 4 5 6 7
A B C @ @ @ ‹ @D E F
1 2 3 4 5 6
A B C @ @ @ ‹ @D E F
1
2
3
4
5
6
A B C @ @ @ ‹ @D E F
Is not displayed
Half of "@" is extracted
Half of "@" is extracted
The KMID$ is used to extract full-byte
characters properly.
For details, see Section 3.13.3.
Unidentifiable
characters are
displayed
" , 7)
" , 6)
" , 6)
2) When using functions that obtain character codes
The ASC function cannot be used to obtain the code numbers for full-byte
characters. To obtain the correct codes, use the JIS$ function (Section 3.13.3)
OK
PRINT HEX$(ASC( "@" ))
82
OK
PRINT JIS$ ( "@" )
2422
OK
The correct code for "@" is 2422h,
but the result is shown as 82h.