8-bit characters and the DirList() function (OpenInsight Specific)
At 29 MAR 1999 11:24:40AM Oystein Reigem wrote:
Just a note to all you guys out there working on apps with international characters. Or am I just talking to myself?:
DirList() and its ilk do not handle ANSI 8-bit characters. So if one has folder and/or file names with 8-bit characters one has to do the necessary conversions oneself.
First (if 8-bit folder names) one must make sure InitDir is fed a path name in MSDOS text:
declare subroutine AnsiToOem
MSDOSPath=Path
AnsiToOem( MSDOSPath, MSDOSPath )
InitDir MSDOSXPath:"\*.*"
If this is the first time one uses the AnsiToOem subroutine one must also declare it. The opposite function - OemToAnsi - is already declared in OI. To declare AnsiToOem open row DLL_KEYBOARD in SYSPROCS:
KEYBOARD
VOID PASCAL OemToAnsi(LPCHAR, LPCHAR)
Add the line
VOID PASCAL AnsiToOem(LPCHAR, LPCHAR)
Then from the Exec line do
run DECLARE_FCNS 'DLL_KEYBOARD'
Second (if 8-bit file names) one must convert the file names returned by DirList from MS-DOS text to ANSI with OemToAnsi. So if FileNames is a @FM-delimited array from DirList, one must
declare subroutine OemToAnsi
NumFileNames=count( FileNames, @FM ) + (FileNames "")
for F=1 to NumFileNames
Temp=FileNames
OemToAnsi( Temp, Temp )
FileNames=Temp
next F
(Don't try to OemToAnsi-convert the whole array. That will make your @FMs into underscores. And don't try to let OemToAnsi return directly into an array element.) (Btw - remember to consult the DirList() docs for how to get back more than 4000 chars of file name data.)
- Oystein -