ANSITOWIDE function

Purpose: ANSITOWIDE function returns a wide-character(Unicode) string converted from a character string.


 Syntax:

 RetLPOLESTR = ANSITOWIDE(Multibyte$ [, CodePage, dwFlags])

 Parameters:

  • RetLPOLESTR Returned pointer to translated wide-character string. RetLPOLESTR should be dimensioned as a LPOLESTR.
  • Multibyte$ Points to the character string to be converted.
  • CodePage [OPTIONAL]. Default is CP_ACP. Specifies the code page to be used to perform the conversion. See the CodePage section of the MultiByteToWideChar function in your Win32 SDK or PSDK Reference help for more information.
  • dwFlags [OPTIONAL]. dwFlags is an integer which indicates how to translate Multibyte$. If flag constants are used for this parameter, the winnnls.h header, which contains the constants, must be specified. The default is MB_PRECOMPOSED. See the dwFlags section of the MultiByteToWideChar function in your Win32 SDK or PSDK Reference help for more information.

WIDETOANSI$ function

Purpose: WIDETOANSI$ function returns a character string converted from a wide-character(Unicode) string.


 Syntax:

 RetStr$ = WIDETOANSI$(UnicodeStr [, CodePage, dwFlags])

 Parameters:

  • RetStr Returned string.
  • UnicodeStr Points to the Unicode string to be converted.
  • CodePage [OPTIONAL]. Default is CP_ACP. Specifies the code page to be used to perform the conversion. See the CodePage section of the WideCharToMultiByte function in your Win32 SDK or PSDK Reference help for more information.
  • dwFlags [OPTIONAL]. dwFlags is an integer which indicates how to translate. If flag constants are used for this parameter, the winnnls.h header, which contains the constants, must be specified. The default value is 0. See the dwFlags section of the WideCharToMultiByte function in your Win32 SDK or PSDK Reference help for more information.

Here is an example to convert a Unicode file to ANSI.


 DIM lenFile%
 lenFile% = LOF("MyUnicode.file")
 DIM a$ * lenFile%
 DIM b AS LPOLESTR
 DIM c$ *  LOF("MyUnicode.file")

 OPEN "MyUnicode.file" FOR BINARY AS fp1
 Get$ fp1, a$, lenFile%
 b =(LPOLESTR)a$
 c$ = WIDETOANSI$(b)

 PRINT c$