National Character String Literals


10.2

 

National Character String Literals behave the same as normal PL/B Language Literals. They are data strings (alpha, numeric, or a combination) that are not declared as variables. However, National Character String Literals can only contain valid UTF-8 encoded characters. They can be used in programs where a constant string value is needed. They may be in one of the following formats:

 

String - a sequence of UTF-8 characters - alpha, numeric and/or other special character that must be valid UTF-8 characters.

 

Character - a single UTF-8 character.

 

Number - a decimal integer number whose byte value is from 0 to 127.

 

Ctrl - binary, decimal, hex or octal representation whose byte value is 0 to 127.

 

Character literals may be defined in any supported numbering base as long as the byte value is from 0 to 127:

 

Decimal 32

Binary 0b00100000

Hexadecimal 0x20

Octal 040

 

The following rules apply to string literals:

  1. A national character string literal must be enclosed in quotes with a leading 'N' character (N"") in PL/B operations. However, when a national character string literal initializes a NCHAR array or NINIT data variable types, only quotes are used.

  2.  

    Example:

    .

    Quote NINIT "?????????? ???????"

    .

           MATCH N"?????????? ???????", Quote

     

  3. A national character string literal may be continued from one line to another by ending the first line with a pair of colons (::).

  4. The Form Pointer is always one while the Length Pointer points to the last UTF-8 character.

  5. National character string literals are generally the first OPERAND in most supported operations. The OPERATION formats are described later.

 

The following examples show how National Character String Literals may be used for OPERANDS:

 

     MOVE N"YEAR-END" TO S$CMDLIN

.

     MOVE n"?????????? ???????", S$CMDLIN

.

     MATCH N"????", S$CMDLIN

 

A national character string literal may be continued on multiple lines:

 

Quote NCHAR 30(3):

                ("My Quote is: '":

                 "?????????? ???????'" ):

                ("Testing:):

                ("Last Name")

.

       MOVE n"My Quote is: '"::

             "?????????? ???????'" TO S$CMDLIN

 

 

See Also: Instruction Syntax

 



PL/B Language Reference Literals Forcing Character