Click or drag to resize

Ansi2Oem Function (Byte, Long)

X#
Convert an array of bytes from ANSI to OEM.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax
 FUNCTION Ansi2Oem(
	bSource AS BYTE[],
	iLen AS LONG
) AS BYTE[]
Request Example View Source

Parameters

bSource
Type: Byte
String in Ansi format
iLen
Type: Long
Length of the source array

Return Value

Type: Byte
A converted string of OEM characters.
Remarks
Ansi2Oem() changes the individual characters in the source string to matching characters from the OEM character set.
This may need to be done because certain symbols, such as ä, have different code values in the ANSI and OEM character sets. DOS applications creating a file with ä as part of the file name use the OEM code values and place 132 into the directory entry. But Windows applications with ANSI code values use 228 for ä and thus cannot find the file.
To get around this problem, you can use Ansi2Oem() to convert ANSI file names to the OEM character set. Also, if characters written to files by Windows applications are in the ANSI character set, the same character conversion problem might arise when DOS applications read the file.
Examples
This example writes the string "aá.TXT" to a DOS file. Note that á has the code value 225 in the ANSI character set, while in the OEM character set, code value 225 corresponds to the ß character.
The FWrite() functions assume raw binary data and thus does not automatically convert ANSI to OEM. (If desired, you could do the conversion yourself or use other functions such as FWriteText().)
X#
1FWrite(ptrFileHandle, Ansi2Oem("aá.txt"))
See Also