Localization: 5.6 Lexical Functions: DOS Text & Code Pages

Up: GEOS SDK TechDocs | Up | Prev: 5.5 Lexical Values
LocalDosToGeos(), LocalGeosToDos(), LocalDosToGeosChar(), LocalGeosToDosChar(), LocalCmpStringsDosToGeos(), LocalIsDosChar(), LocalCodePageToGeos(), LocalGeosToCodePage(), LocalCodePageToGeosChar(), LocalGeosToCodePageChar(), LocalGetCodePage(), LocalIsCodePageSupported()

There are several functions which work with DOS-format text, converting it to and from GEOS format. Normally, converting DOS text files to GeoWrite documents is handled by Import/Export routines; for those occasions where your code needs to convert DOS text to GEOS format or vice versa, however, these functions should be sufficient. They are localized because DOS has its own version of localization which it implements as "code pages." Each code page is a table of characters. Countries or regions with unusual characters have different code pages. If you haven't worked with code pages up to this point, you probably won't have to start now but can just rely on GEOS to use the native code page correctly. If your geode is going to allow computers from one country to communicate with those of another, you might need to use specialized functions.

Assuming you want to use the code page native to the user's machine, you can use LocalDosToGeos() and LocalGeosToDos() to convert strings from one text format to the other. LocalDosToGeosChar() and LocalGeosToDosChar() work similarly, converting a single character.

LocalCmpStringsDosToGeos() takes two strings, converts one or both of them to GEOS format, then compares them, returning the same values as the regular string comparing functions. Pass a LocalCmpStringsDosToGeosFlags to specify which strings to convert before comparing.

Each of these functions also takes a character as an argument. When a character in one format has no corresponding character in the format it's being converted to, the character argument will be substituted. At the same time a flag will be set to let your geode know that there were some characters that couldn't be converted nicely. LocalIsDosChar() checks a GEOS character to see if it maps into a DOS character. The MIN_MAP_CHAR constant is the smallest value which may need to be mapped. If a character's value is below this constant, then it will be the same under any code page.

If your geode is interested in which code page it's using, the LocalGetCodePage() instruction will tell you what the default code page is. If you want to use a code page other than the native one, the LocalCodePageToGeos() , LocalGeosToCodePage() , LocalCodePageToGeosChar() , and LocalGeosToCodePageChar() behave as their default code page equivalents, except that each takes a code page as an argument to be used in conversion. A number of support code page values are enumerated in the DosCodePage type. To find out whether the user's environment supports a specific code page, call LocalIsCodePageSupported() .

 


Up: GEOS SDK TechDocs | Up | Prev: 5.5 Lexical Values