Return and optionally change the setting that determines whether database files are created using ANSI or OEM format and whether certain text file operations convert between the two character sets.
XSharp.Core (in XSharp.Core.dll) Version: 2.6
Syntax Request Example
FUNCTION GetAnsi() AS LOGIC
public static bool GetAnsi()
If <lNewSetting> is not specified, SetAnsi() returns the current setting.
If <lNewSetting> is specified, the previous setting is returned.
SetAnsi() is a dual purpose function.
First and foremost, it determines the format used to create new database files — ANSI, which uses the Windows character set, or OEM, which uses the ASCII character set. Thus, functions such as DBCreate() and DBCopyStruct() are affected by this setting.
The information that determines the ANSI/OEM format of a database file is stored in the header record of the file.
If your application must share data with a DOS-based product, either simultaneously or at different times, you must use the OEM format when creating .DBF files.
If SetAnsi() is TRUE, your X# application will perform an automatic conversion between OEM and ANSI for existing database files that are in OEM format, thereby preserving the format of the data and allowing it to be used by other applications that do not support the ANSI format.
Is SetAnsi() is FALSE, however, no automatic conversion is performed when reading to or writing from any database file. In this case, the data will appear at runtime just as it was read from disk.
For OEM databases, therefore, the programmer is fully responsible for ANSI/OEM conversion of displayed data or data modified by any edit control or terminal function. You can use the Ansi2Oem() and Oem2Ansi() functions to convert data between the two formats.
The second purpose of SetAnsi() is to control how functions that read and write text files deal with the two different character sets. When SetAnsi() is FALSE, functions that read from text files (FReadText() and MemoRead()) and write to text files (FWriteText() and MemoWrit()) automatically convert between ANSI to OEM. When SetAnsi() is TRUE, these functions perform no conversion.
Independent of SetAnsi(), however, all data that is read or written using the FRead(), FWrite(), and related functions is not converted to and from the OEM character set.
This example stores the SetAnsi() setting in the beginning of an application and restores it to its original setting at the end:
1METHOD Start() CLASS App
2 LOCAL lAnsiSetting AS LOGIC
3 lAnsiSetting := SetAnsi(FALSE)