SPL to HP C/XL Migration Guide (30231-90001)
3- 10
String Constants
Table 3-17. String Constants
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| Type: BYTE | Type: string literal OR unsigned char |
| | |
---------------------------------------------------------------------------------------------
| | |
|
string-constant
: |
string-literal
: |
| | |
| "
characters
" | "
characters
" |
| | |
---------------------------------------------------------------------------------------------
| | |
|
characters
|
characters
|
| is one or more ASCII characters (up to | is zero or more ASCII characters. A |
| 127). A quotation mark (""") within | quotation mark, """, within
characters
is |
|
characters
is doubled. | represented by the "escape sequence" |
| | "\"", an apostrophe, "'", by "\'", and a |
| | backslash, "\", by "\\". |
| | |
---------------------------------------------------------------------------------------------
| | |
| For example, the string | For example, the string |
| | |
|
He said, "Hi."
|
He said, "Hi."
|
| | |
| is entered as: | is entered as: |
| | |
| "He said, ""Hi.""" | "He said, \"Hi.\"" |
| | |
---------------------------------------------------------------------------------------------
| | |
| Characters are stored two to the 16-bit | Characters are stored as a series of 8-bit |
| word, left justified. | bytes. The string literal is terminated by |
| | HP C/XL with the ASCII NUL character ('\0', |
| | numeric value 0). This fact is used by |
| | many HP C/XL string manipulation functions |
| | that might be used to emulate SPL string |
| | operations. |
| | |
---------------------------------------------------------------------------------------------
HP C/XL also has a character constant, in the form:
'
char
'
where
char
is a single character, or a special escape sequence using a
leading "\" character, such as those shown above. Escape sequences can
be used in character and string constants to represent any of the 256
ASCII character codes. Consult the
HP C Reference Manual
for further
details.