ANSI and Unicode versions of DTWAIN functions

Top  Previous  Next

There are now DTWAIN API functions that have names that end with the letter A or W.  The functions that end with "A" are ANSI specific string functions, and the functions that end with "W" are wide-string/Unicode specific string functions.

 

For example, DTWAIN_GetErrorStringA, DTWAIN_GetErrorStringW are ANSI and Unicode specific functions for the function DTWAIN_GetErrorString, since DTWAIN_GetErrorString has as one of the arguments a pointer to a string (LPTSTR).  For DTWAIN_GetErrorStringA, the string must be an ANSI string, for DTWAIN_GetErrorStringW, the string must be a Unicode string.

However, it is highly suggested that if you're developing a Unicode application, to refrain from calling the "A" versions of these functions.   Similarly, if you're developing an ANSI version of the DTWAIN DLL, you should rarely, if ever call the DTWAIN "W" functions explicitly. Only when you deem it necessary and safe should you call the DTWAIN string-related functions that are ANSI or Unicode specific.

 

Calling the "A" or "W" specific functions may require a string conversion to be done internally by DTWAIN.  This internal conversion is slower than just making the "natural" call to the DTWAIN DLL function (in our example, the "natural" function would be DTWAIN_GetErrorString).  In addition, the translation may not work correctly due to code page interpretation and other issues.

 

So please use caution when calling the "A" or "W" versions of the DTWAIN functions that handle strings.  Make sure that if you're calling the ANSI/Unicode specific functions, your application will behave correctly and consistently with respect to locale, code pages in effect, etc.