All functions in this Toolkit that pass a filename as an argument only support filenames in single-byte "ANSI" encoding.
So ASCII and Latin-1 filenames like abcdef.txt
and México.xml
are OK, but a Chinese filename like
你好.txt
will fail.
To solve this, use a little-known hack on Windows that retrieves the short path name of a file, GetShortPathName
.
This was originally designed to provide an MS-DOS-compatible form of a file path where each folder name and filename is 8 characters or fewer.
So, for example, the long name
C:\Test\Documents and Settings\My Documents\ForEmailWithALongNameLikeThisFolderHas\helloFileWithaLongNameToo.txt
reduces to something like
C:\Test\DOCUME~1\MYDOCU~1\FOREMA~1\HELLOF~1.TXT
where each component of the path name is 8 characters or fewer.
It turns out that this function will provide an ASCII-character equivalent of the name of a file in any Windows "International" UTF-16 characters. The short name is safe to use with any function in this Toolkit that requires a filename parameter.
Use the function CNV_ShortPathName
to get a ASCII filename that will work with any function in this Toolkit. Examples:
System Filename | ShortPathName |
---|---|
你好.txt | FC0F~1.TXT |
こんにちは世界.txt | C001~1.TXT |
Приветмир.txt | E173~1.TXT |
The exact short path name may be different on your system.
The file path must exist, though. So if you want to output to a file with a name in, say, Japanese or Chinese characters, then you must create a dummy file of the required name, get its short path name, and then output to a file of that name, which will automatically overwrite the original dummy file.