Internationalization and localization tools


Locale-Sensitive C/C++ Collation Function

int _strncoll(const char *string1, const char string2, size_t count);

int _mbsnbcoll(const unsigned char *string1, const unsigned char string2, size_t count);

int _mbsncoll(const unsigned char *string1, const unsigned char string2, size_t count);

int _wcsncoll(const wchar_t *string1, const wchar_t string2, size_t count);

int _tcsncoll(const _TXCHAR *string1, const _TXCHAR string2, size_t count);

int _tcsnccoll(const _TXCHAR *string1, const _TXCHAR string2, size_t count);

Internationalization (I18n) Function Overview

The _strncoll function compares count specified characters in two strings, using the currently selected code page.

_mbsnbcoll is the multibyte character version that compares bytes in the multibyte strings; whereas _mbsncoll compares multibyte characters in the strings.

_wcsncoll is the wide-character version that compares wide-character strings.

_tcsncoll and _tcsnccoll are the Generic versions of the function; when the Windows _MBCS compiler flag is set, _tcsncoll maps to _mbsnbcoll and _tcsnccoll maps to _mbsncoll. When the Windows _UNICODE flag is set, the Generic functions both map to _wcsncoll.

I18n Issues

Use the appropriate version of the function as required for internationalization support, noting the following:

The single-byte version of the function, _strncoll, should not be used for collation because it will only work with single-byte characters. Instead, the appropriate multibyte, wide or generic version should be called.

Ensure that the count argument value is correct for the chosen platform and function call; the number of bytes for _mbsnbcoll, the number of multibyte characters for _mbsncoll, and the number of wide characters for _wcsncoll. See Locale-Sensitive Length Functions for a discussion on multibyte and wide character sizes.

The locale for which this function draws its collation rules can be set via setlocale.

In the case of multibyte characters, ensure that the multibyte code page is set correctly before calling the multibyte or generic version of this function. See _setmbcp for more information on setting up the multibyte code page.

Recommended Function Replacements

Collation Functions

 

Lingoport internationalization and localization services and software