Product SiteDocumentation Site

8.29. SysFromUnicode (Windows only)


>>-SysFromUnicode--(--string, codepage, mappingflags,----------->

>--, defaultchar, outstem--)-----------------------------------><

Maps a UNICODE character string to an ASCII character string. The new character string and additional information is returned in the outstem.
Parameters:
string
A string containing the UNICODE characters to be mapped.
codepage
Specifies the code page used to perform the conversion. This parameter can be the value of any code page that is installed or available in the system. The default is the current original equipment manufacturer (OEM) code-page identifier for the system.
You can also specify one of the following values:
ACP
ANSI code page.
OEMCP
OEM code page.
SYMBOL
Windows 2000: symbol code page.
THREAD_ACP
Windows 2000: current thread's ANSI code page.
UTF7
Windows NT 4.0 and Windows 2000: translate using UTF-7.
UTF8
Windows NT 4.0 and Windows 2000: translate using UTF-8. When this is set, mappingflags must be set.
mappingflags
Specifies the handling of unmapped characters. The function performs more quickly when none of these flags is set.
The following flags can be used:
COMPOSITECHECK
Converts composite characters to precomposed characters.
SEPCHARS
Generates separate characters during conversion. This is the default conversion behavior.
DISCARDNS
Discards nonspacing characters during conversion.
DEFAULTCHAR
Replaces non-convertible characters with the default character during conversion.
When compositecheck is specified, the function converts composite characters to precomposed characters. A composite character consists of a base character and a nonspacing character, each having different character values. A precomposed character has a single character value for a combination of a base and a nonspacing character. In the character è, the "e" is the base character, and the "grave" accent mark is the nonspacing character.
When compositecheck is specified, it can use the last three flags in this list (discardns, sepchars, and defaultchar) to customize the conversion to precomposed characters. These flags determine the function's behavior when there is no precomposed mapping for a combination of a base and a nonspace character in a Unicode character string. These last three flags can be used only if the compositecheck flag is set. The function's default behavior is to generate separate characters (sepchars) for unmapped composite characters.
defaultchar
Character to be used if a Unicode character cannot be represented in the specified code page. If this parameter is NULL, a system default value is used. The function is faster when defaultchar is not used.
outstem
The name of the stem variable that will contain the converted result. If the conversion was successful the stem will be composed of the following value(s):
outstem.!USEDDEFAULTchar
This variable will be set to "1" if the defaultchar was used during the conversion and "0" if it was not.
outstem.!TEXT
This variable will contain the converted string.
Return codes:
0
No errors.
Other
An error occurred. A Windows System Error code (Section 8.1, “A Note on Error Codes”) is returned. This may be one of the following, but could be others.
87
Incorrect code page or codepage value.
1004
Invalid mapping flags.