It does not matter whatever codepage the file names are encoded or the contents of the file are encoded.
Here is a sample to copy files matching the mast "My*File.txt" contained in the source folder "c:\natfiles\src\" into the destination folder "c:\natfiles\dst\" folder.
This is directory of c:\natfiles\src\
This folder contains 6 files. Two of them do not match the mask.
4 files match the mask. Each of them is encoded in different codepage.
1) MyOwnFile.txt (simple English)
2) MyÄÅÆFile.txt (WU ANSI codepage 1252)
3) MyДЕЖFile.txt (Russian ANSI codepage 1251)
4) MyమనవFile.txt (UTF8 codepage of any Unicode language, in this case, Telugu)
I propose 2 approaches to copy these 4 matching files into the destination folder.
function CopyX()
WaitRun( "xcopy " + cSrcDir + "my*file.txt " + cDstDir + " /Y" )
? "Copied"
return nil
another:
function CopyHB()
HB_CDPSELECT( "UTF8" )
XBROWSER( aFiles := DIRECTORY( cSrcDir + "My*File.txt" ) )
AEval( aFiles, { |a| FileCopy( cSrcDir + a[1], cDstDir + a[1] ) } )
? "copied"
return nil
In both the cases the matching files are copied into the destination folder and also retain their original codepage encodings.
Note: Tested and working with Harbour.