Click or drag to resize

Functions.Oem2Ansi Method (String)

Convert a string of OEM characters to ANSI characters.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.16
	cOemString AS STRING
Request Example View Source


Type: String
A source string of OEM characters.

Return Value

Type: String
A converted string of ANSI characters.
Oem2Ansi() converts the individual characters in the source string to matching characters from the ANSI character set.
This may need to be done because certain symbols, such as ß, have different code values in the ANSI and OEM character sets.
Therefore, when using Windows to read or display DOS string data or file names, it is often necessary to translate characters from OEM to ANSI. Note that most X# for Clipper applications automatically perform an OEM to ANSI conversion when SetAnsi() is FALSE. Some, however, such as FRead(), that assume they are working with binary data, do not do such a conversion.
Caution note Caution
The Ansi2Oem() and Oem2Ansi() family of functions are compatibility functions. Do not use them unless you really have to. X# is a Unicode language and conversions from Unicode - Ansi - Oem - Unicode will take place if you use these functions.
You should also realize that Ansi2Oem(Oem2Ansi(cSource)) will not always return cSource. Some characters may not be available in the OEM codepage and could be translated to other characters. For example: Windows codepage 1252 has Capital E Umlaut (Ë) on position 203. When translated to OEM codepage 437 this will become capital E without umlaut (69). Converting back to Ansi this will remain a E without umlaut.
This example uses Oem2Ansi() to convert OEM characters to ANSI characters in order to read a DOS file into Windows:
2// no conversion between ANSI and OEM
4// do the conversion yourself if needed
See Also