title: WideCharToMultiByte in QB64
body: <p>Am having problems converting from ANSI to Unicode and back. The following code snip describes what I am doing. I am getting 0x57 errors..</p>
  
  <pre><code>DECLARE DYNAMIC LIBRARY "kernel32"
      FUNCTION MultiByteToWideChar&amp; (codePage~&amp;, dwFlags~&amp;, lpszMbstring$, byteCount&amp;, lpwszWcstring$, wideCount&amp;)
      FUNCTION WideCharToMultiByte&amp; (codePage~&amp;, dwFlags~&amp;, lpWideString$, BYVAL ccWideChar%, lpMultiByte$, BYVAL multibyte%, BYVAL defaultchar&amp;, BYVAL usedchar&amp;)
      FUNCTION GetLastError&amp; ()
  END DECLARE
  DIM Filename AS STRING * 260, NewFilename AS STRING * 260, MultiByte AS STRING * 260
  PRINT "Enter filename";: INPUT Filename$: 'Filename$ = Filename$ + CHR$(0)
  x = MultiByteToWideChar(0, 0, Filename$, LEN(Filename$), NewFilename$, 260)
  IF x = 0 THEN
      PRINT "Error 0x"; HEX$(GetLastError)
  ELSE
      PRINT "Processing: "; NewFilename$
  END IF
  ' do unicode stuff here
  x = WideCharToMultiByte(65001, 0, NewFilename$, LEN(NewFilename$), MultiByte$, 0, 0, 0)
  ' display processed filename
  IF x = 0 THEN
      PRINT "Error 0x"; HEX$(GetLastError)
  ELSE
      PRINT MultiByte$
  END IF
  </code></pre>