You are here: Function Reference > Alphabetical Listing > C > CPSTR

CPSTR

Use this function to convert a string constant, or any value from a string variable, to a specific code page number.

Syntax

CPSTR('TextString', Codepage)

Parameter

Description

TextString

Enter the string constant or variable.

Codepage

Enter the code page value.

You can choose from these code pages:

  • 1250 — Central and East European Latin
  • 1251 — Cyrillic
  • 1252 — West European Latin
  • 1253 — Greek
  • 1254 — Turkish
  • 1257 — Baltic
  • 65001 — Unicode (UTF-8 encoded )

If no CodePage and Locale values have been set, the system will use a default value of 1252. Code page 1252 is a character encoding of the Latin alphabet that represents English and Western European languages.

Note If the code page of the first parameter value does not match the desired code page, then the string is first converted up to Unicode (UTF-8) and then converted down to the code page specified in the second parameter. Characters that do not map to the desired code page will appears as question marks in the resulting string.

Subroutine Example

The following subroutine demonstrates the CPSTR function by creating a text variable called RUSSIANVARIABLE that contains a Russian text string.

BEGINSUB TestCPSTR
...
RUSSIANVARIABLE = CPSTR('Это текст на русском языке', 1251)
...
ENDSUB

Statement Examples

Statement

Description of results

ABC = CPSTR("Truth is αλήθεια in Greek", 1253)

The string value is converted to the single-byte (Greek) code page 1253 and then assigned into the DAL variable ABC.

(Assumes that Windows is configured for Greek or that the script is set up for Unicode (UTF-8 encoding).)

DECLARE("XYZ", 65001)

XYZ = CPSTR("Truth is αλήθεια in Greek", 65001)

Create the resulting string using the Unicode code page (UTF-8) and stores it into the DAL variable XYZ which was previously declared to use the Unicode code page. See DECLARE for more information.

See Also