--- In [email protected], "swzoh" <sean...@...> wrote:
>
> --- In [email protected], "swzoh" <seanzoh@> wrote:
> > No, it doesn't detect 0x920x7C as an invalid multibyte character, i.e., 
> > just return 2. All I tried so far doesn't work perfectly: mblen, CharNext.
> >
> I've been unable to find a single API which both detects and validates a 
> double-byte character. The best way appeared to me so far seems to validate 
> using MultiByteToWideChar after detecting it.
> 
> MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, lpChar, 2, NULL, 0)
>
I think I nailed down why mblen didn't work as expected. Now it seems to work 
as documented.

setlocale(LC_CTYPE, "")
mblen(lpChr, MB_CUR_MAX)

Although I hard-coded 2 in place of MB_CUR_MAX, I suppose it's meant to be used 
this way.
http://msdn.microsoft.com/en-us/library/aa272906.aspx
http://msdn.microsoft.com/en-us/library/aa298462.aspx

Reply via email to