c++windowsunicodetcharmbcs

tchar safe functions -- count parameter for UTF-8 constants


I'm porting a library from char to TCHAR. the count parameter of this fragment, according to MSDN, is the number of multibyte characters, not the number of bytes. so, did I get this right? My project properties in VC9 say 'use unicode character set' and I think that's correct, but I'm not how that impacts my count parameter.

_tcsncmp(access, TEXT("ftp"), 3); //or do i want _tcsnccmp?

"Supported on Windows platforms only, _mbsncmp and _mbsnbcmp are multibyte versions of strncmp. _mbsncmp will compare at most count multibyte characters and _mbsnbcmp will compare at most count bytes. They both use the current multibyte code page.

_tcsnccmp and _tcsncmp are the corresponding Generic functions for _mbsncmp and _mbsnbcmp, respectively. _tccmp is equivalent to _tcsnccmp."

A similar question is _tcslen vs _tcsclen.


Solution

  • Yes, you get it right.

    The question, however, is why do you port it to TCHAR - something that is sensitive to _UNICODE define.

    Why not use UTF8 and char*?