CryptoSys API Library Manual

Filenames with "International" characters

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


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 FilenameShortPathName

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.

[Contents] [Index]

[PREV: Correct sequence for AEAD incremental functions...]   [Contents]   [Index]   
   [NEXT: Security Issues...]

Copyright © 2001-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-05-27T11:37:34Z.