James
I just saw your post, but this is how I do it, this also works with the code page and dwflags parameters.
I manually change WideToAnsi$ to WideToAnsiW and AnsiToWide to AnsiToWideW in my code to stop BCX, and then adding thes substitute functions below, the lexer needs to translate MultiByteToWideChar to MultiByteToWideCharW for these to work. Fortunately there are only a few functions that I need to do this for, these can be found in
https://bcxbasiccoders.com/bcxusers/ian/programs/Uni_functions.zip Ian
In the unicode lexer make sure to add these if they are missing.
MultiByteToWideCharW,MultiByteToWideCharW,MultiByteToWideChar
WideCharToMultiByte, , ,SKIP
' Erase functions
WideToAnsi, , ,ERASEF
AnsiToWide, , ,ERASEF
LoadFile, , ,ERASEF '<- if adding the whole Uni_functions.bas file
FUNCTION MultiByteToWideCharW(CP AS UINT,Flags AS DWORD, cText$, length AS INTEGER, sRet$, szBuf AS INTEGER)
sRet$ = cText$
FUNCTION = LEN(sRet$)
END FUNCTION
$CCODE funcsub
//<---UNICODE AWARE
char* WideToAnsiW (BSTR, UINT=CP_ACP, DWORD=0);
char* WideToAnsiW (BSTR WideStr, UINT CodePage,DWORD dwFlags)
{
char *BCX_RetStr={0};
UINT uLen;
uLen=WideCharToMultiByte(CodePage,dwFlags,WideStr,-1,0,0,0,0);
BCX_RetStr=(char*)BCX_TmpStr(uLen); //Added char*
WideCharToMultiByte(CodePage,dwFlags,WideStr,-1,BCX_RetStr,uLen,0,0);
return BCX_RetStr;
}
//LPOLESTR AnsiToWideW (char*,UINT=CP_ACP,DWORD=MB_PRECOMPOSED);
_TCHAR* AnsiToWideW (char*,UINT=CP_ACP,DWORD=MB_PRECOMPOSED);
//LPOLESTR AnsiToWideW (char *AnsiStr, UINT CodePage,DWORD dwFlags)
_TCHAR* AnsiToWideW (char *AnsiStr, UINT CodePage,DWORD dwFlags)
{
UINT uLen;
BSTR WideStr;
uLen=MultiByteToWideChar(CodePage,dwFlags,AnsiStr,-1,0,0);
if(uLen<=1) return (BSTR) BCX_TmpStr(2);
WideStr=(BSTR) BCX_TmpStr(2*uLen);
MultiByteToWideChar(CodePage,dwFlags,AnsiStr,uLen,WideStr,uLen);
return WideStr;
}
//>---UNICODE AWARE
$CCODE