The following functions, macros, and classes are provided in string.h:
Name |
Description |
Header File mbstring.h Category Classification Routines Prototype int _ismbblead(unsigned int c); int _ismbbtrail(unsigned int c); Description _ismbblead and _ismbbtrail are used to test whether the argument c is the first or the second byte of a multibyte character. _ismbblead and _ismbbtrail are affected by the code page in use. You can set the code page by using the _setlocale function. Return Value If c is in the lead byte of a multibyte character, _ismbblead returns true. If c is in the trail byte of a multibyte character, _ismbbtrail returns a nonzero value. | |
Header File mbstring.h Category Classification Routines Prototype int _ismbclegal(unsigned int c); Description _ismbclegal tests whether each byte of the c argument is in the code page that is currently in use. Return Value _ismbclegal returns a nonzero value if the argument c is a valid multibyte character on the current code page. Otherwise, the function returns zero. | |
Header File mbstring.h Category Classification Routines Prototype int _ismbslead(const unsigned char *s1, const unsigned char *s2); int _ismbstrail(const unsigned char *s1, const unsigned char *s2); Description The _ismbslead and _ismbstrail functions test the s1 argument to determine whether the s2 argument is a pointer to the lead byte or the trail byte. The test is case-sensitive. Return Value The _ismbslead and _ismbstrail routines return -1 if s2 points to a lead byte or a trail byte, respectively. If the test is false, the routines return zero. | |
Header File mbstring.h Category Classification Routines Prototype int _mbbtype(unsigned char ch, int mode); Description The _mbbtype function inspects the multibyte argument, character ch, to determine whether it is a single-byte character, or whether ch is the leadbyte or trailing byte in a multibyte character. The _mbbtype function can determine whether ch is an invalid character. Return Value The value that _mbbtype returns is one of the following manifest constants, defined in mbctype.h. The return value depends on the value of ch and the test which you want performed on ch. | |
Header File mbstring.h Category Memory and String Manipulation Routines Prototype void _mbccpy(unsigned char *dest, unsigned char *src); Description The _mbccpy function copies a multibyte character from src to dest. The _mbccpy function makes an implicit call to _ismbblead so that the src pointer references a lead byte. If src doesn’t reference a lead byte, no copy is performed. Return Value None. | |
Header File mbstring.h Category Classification Routines Prototype int _mbsbtype(const unsigned char *str, size_t nbyte); Description The nbyte argument specifies the number of bytes from the start of the zero-based string. The _mbsbtype function inspects the argument str to determine whether the byte at the position specified by nbyte is a single-byte character, or whether it is the leadbyte or trailing byte in a multibyte character. The _mbsbtype function can determine whether the byte pointed at is an invalid character or a NULL byte. Any invalid bytes in str before nbyte are ignored. Return Value The value that _mbsbtype returns is... more | |
Header File mbstring.h Category Memory and String Manipulation Routines Prototype int _mbsnbcmp(const unsigned char *s1, const unsigned char s2, size_t maxlen); Description _mbsnbcmp makes an case-sensitive comparison of s1 and s2 for no more than maxlen bytes. It starts with the first byte in each string and continues with subsequent bytes until the corresponding bytes differ or until it has examined maxlen bytes. _mbsnbcmp is case sensitive. _mbsnbcmp is not affected by locale. _mbsnbcmp compares bytes based on the current multibyte code page. Return Value
| |
Header File mbstring.h Category Memory and String Manipulation Routines Prototype size_t _mbsnbcnt(const unsigned char * str, size_t nmbc); size_t _mbsnccnt(const unsigned char * str, size_t nbyte); Description If _MBCS is defined: _mbsnbcnt is mapped to the portable macro _tcsnbcnt _mbsnccnt is mapped to the portable macro _tcsnccnt If _UNICODE is defined: both _mbsnbcnt and _mbsnccnt are mapped to the _wcsncnt macro If neither _MBCS nor _UNICODE are defined. _tcsnbcnt and _tcsnccnt are mapped to the _strncnt macro _strncnt is the single-byte version of these functions. _wcsncnt is the wide-character version of these functions. _strncnt and _wcsncnt are available only for... more | |
Header File mbstring.h Category Memory and String Manipulation Routines Prototype int _mbsnbcoll(const unsigned char *s1, const unsigned char *s2, maxlen); int _mbsnbicoll(const unsigned char *s1, const unsigned char *s2, maxlen); Description _mbsnbicoll is the case-insensitive version of _mbsnbcoll. These functions collate the strings specified by arguments s1 and s2. The collation order is determined by lexicographic order as specified by the current multibyte code page. At most, maxlen number of bytes are collated. Note: Note: The lexicographic order is not always the same as the order of characters in the character set.If the last byte in s1 or s2 is... more | |
Header File mbstring.h Category Memory and String Manipulation Routines Prototype unsigned char *_mbsnbcpy(unsigned char *dest, unsigned char *src, size_t maxlen); Description The _mbsnbcpy function copies at most maxlen number of characters from the src buffer to the dest buffer. The dest buffer is null terminated after the copy. It is the user’s responsibility to be sure that dest is large enough to allow the copy. An improper buffer size can result in memory corruption. Return Value The function returns dest. | |
Header File mbstring.h Category Memory and String Manipulation Routines Prototype int _mbsnbicmp(const unsigned char *s1, const unsigned char s2, size_t maxlen); Description _mbsnbicmp ignores case while making a comparison of s1 and s2 for no more than maxlen bytes. It starts with the first byte in each string and continues with subsequent bytes until the corresponding bytes differ or until it has examined maxlen bytes. _mbsnbicmp is not case sensitive. _mbsnbicmp is not affected by locale. _mbsnbicmp compares bytes based on the current multibyte code page. Return Value
| |
Header File mbstring.h Category Memory and String Manipulation Routines Prototype unsigned char *_mbsnbset(unsigned char str, unsigned int ch, size_t maxlen); Description _mbsnbset sets at most maxlen number of bytes in the string str to the character ch. The argument ch can be a single or multibyte character. The function quits if the terminating null character is found before maxlen is reached. If ch is a multibyte character that cannot be accomodated at the end of str, the last character in str is set to a blank character. Return Value strset returns str. | |
Header File mbstring.h Category Memory and String Manipulation Routines Prototype unsigned char *_mbsninc(const unsigned char *str, size_t num); Description The functions increment the character array str by num number of characters. These functions should be accessed through the portable macro, _tcsninc, defined in tchar.h. Return value The functions return a pointer to the resized character string specified by the argument str. | |
Header File mbstring.h Category Memory and String Manipulation Routines Prototype unsigned char *_mbsspnp(const unsigned char *s1, const unsigned char *s2); Description Each of these functions search for the first character in s1 that is not contained in s2. Use the portable macro, _tcsspnp, defined in tchar.h, to access these functions. Return Value The functions return a pointer to the first character in s1 that is not found in the character set for s2. If every character from s1 is found in s2, each of the functions return NULL. | |
Header File mbstring.h, tchar.h Category Memory and String Manipulation Routines Prototype unsigned char *_mbsdec(const unsigned char *s, const unsigned char *p); inline char *_strdec(const char * s1, const char * s2) { return (char *)(s1,(s2-1)); // From tchar.h #define _tcsdec _strdec #define _tcsdec _wcsdec Description _mbsdec returns a pointer p indicating the character in string s back to 1 byte backward. If there are no more characters before string p (it is the same position as s), _mbsdec returns a null pointer. _strdec is the single-byte version of this function. _wcsdec is the wide-character version of this function. Return Value... more | |
Header File string.h, stdio.h Category Memory and String Manipulation Routines Prototype char *_strerror(const char *s); Description Builds a customized error message. _strerror lets you generate customized error messages; it returns a pointer to a null-terminated string containing an error message.
_strerror returns a pointer to a constructed error string.... more | |
Header File mbstring.h, tchar.h Category Memory and String Manipulation Routines Prototype unsigned char *_mbsinc(const unsigned char *p); // From tchar.h #define _tcsinc _strinc #define _tcsinc _wcsinc inline char * strinc(const char * s) { return (char *)(s+1); } Description _mbsinc increments a string pointer by one byte. _strdec is the single-byte version of this function. _wcsdec is the wide-character version of this function. Return Value Returns a pointer that is forwarded by 1 byte. | |
Header File tchar.h, mbstring.h Category Memory and String Manipulation Routines Prototype unsigned int _strnextc(const char *str); unsigned int _mbsnextc (const unsigned char *str); Description These routines should be accessed by using the portable _tcsnextc function. The functions inspect the current character in str. The pointer to str is not advanced. Return Value The functions return the integer value of the character pointed to by str. Example | |
Header File string.h Category Memory and String Manipulation Routines Prototype char *stpcpy(char *dest, const char *src); wchar * _wcspcpy(wchar *dest, const wchar *src); Description Copies one string into another. _stpcpy copies the string src to dest, stopping after the terminating null character of src has been reached. Return Value stpcpy returns a pointer to the terminating null character of dest. If UNICODE is defined, _wcspcpy returns a pointer to the terminating null character of the wchar_t dest string. Example | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines, Inline Routines Prototype char *strcat(char *dest, const char *src); wchar_t *wcscat(wchar_t *dest, const wchar_t *src); unsigned char *_mbscat(unsigned char *dest, const unsigned char *src); Description Appends one string to another. strcat appends a copy of src to the end of dest. The length of the resulting string is strlen(dest) + strlen(src). Return Value strcat returns a pointer to the concatenated strings. Example | |
Header File string.h Category Memory and String Manipulation Routines, Inline Routines, C++ Prototyped Routines Prototype char *strchr(const char *s, int c);/* C only */ const char *strchr(const char *s, int c);// C++ only char *strchr( char *s, int c);// C++ only wchar_t *wcschr(const wchar_t *s, int c); unsigned char * _mbschr(const unsigned char *s, unsigned int c); Description Scans a string for the first occurrence of a given character. strchr scans a string in the forward direction, looking for a specific character. strchr finds the first occurrence of the character c in the string s. The null-terminator is considered to... more | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines, Inline Routines Prototype int strcmp(const char *s1, const char *s2); int wcscmp(const wchar_t *s1, const wchar_t *s2); int _mbscmp(const unsigned char *s1, const unsigned char *s2); Description Compares one string to another. strcmp performs an unsigned comparison of s1 to s2, starting with the first character in each string and continuing with subsequent characters until the corresponding characters differ or until the end of the strings is reached. Return Value | |
Header File string.h, wchar.h Category Memory and String Manipulation Routines Prototype int strcmpi(const char *s1, const char *s2); int _wcscmpi(const wchar_t *s1, const wchar_t *s2); Description Compares one string to another, without case sensitivity. strcmpi performs an unsigned comparison of s1 to s2, without case sensitivity (same as stricmp--implemented as a macro). It returns a value (< 0, 0, or > 0) based on the result of comparing s1 (or part of it) to s2 (or part of it). The routine strcmpi is the same as stricmp. strcmpi is implemented through a macro in string.h and translates calls from strcmpi... more | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines Prototype int strcoll(const char *s1, const char *s2); int wcscoll(const wchar_t *s1, const wchar_t *s2); int _stricoll(const char *s1, const char *s2); int _wcsicoll(const wchar_t *s1, wconst_t char *s2); int _mbscoll(const unsigned char *s1, const unsigned char *s2); int _mbsicoll(const unsigned char *s1, const unsigned char *s2); Description Compares two strings. strcoll compares the string pointed to by s1 to the string pointed to by s2, according to the current locale's LC_COLLATE category. _stricoll performs like strcoll but is not case sensitive. Note: Note _stricoll does not compare string according... more | |
Header File string.h, wchar.h, mbstring.h Category Memory and String Manipulation Routines, Inline Routines Prototype char *strcpy(char *dest, const char *src); wchar_t *wcscpy(wchar_t *dest, const wchar_t *src); unsigned char *_mbscpy(unsigned char *dest, const unsigned char *src); Description Copies one string into another. Copies string src to dest, stopping after the terminating null character has been moved. Return Value strcpy returns dest. Example | |
Header File string.h, wchar.h, mbstring.h Category Memory and String Manipulation Routines Prototype size_t strcspn(const char *s1, const char *s2); size_t wcscspn(const wchar_t *s1, const wchar_t *s2); size_t _mbscspn(const unsigned char *s1, const unsigned char *s2); Description Scans a string for the initial segment not containing any subset of a given set of characters. The strcspn functions search s1 until any one of the characters contained in s2 is found. The number of characters which were read in s1 is the return value. The string termination character is not counted. Neither string is altered during the search. Return Value strcspn returns... more | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines Prototype char *strdup(const char *s); wchar_t *_wcsdup(const wchar_t *s); unsigned char *_mbsdup(const wchar_t *s); Description Copies a string into a newly created location. strdup makes a duplicate of string s, obtaining space with a call to malloc. The allocated space is (strlen(s) + 1) bytes long. The user is responsible for freeing the space allocated by strdup when it is no longer needed. Return Value strdup returns a pointer to the storage location containing the duplicated string, or returns null if space could not be allocated. Example | |
Header File string.h Category Memory and String Manipulation Routines Prototype char *strerror(int errnum); Description Returns a pointer to an error message string. strerror takes an int parameter errnum, an error number, and returns a pointer to an error message string associated with errnum. Return Value strerror returns a pointer to a constructed error string. The error message string is constructed in a static buffer that is overwritten with each call to strerror. Example | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines Prototype int stricmp(const char *s1, const char *s2); int _wcsicmp(const wchar_t *s1, const wchar_t *s2); int _mbsicmp(const unsigned char *s1, const unsigned char *s2); Description Compares one string to another, without case sensitivity. stricmp performs an unsigned comparison of s1 to s2, starting with the first character in each string and continuing with subsequent characters until the corresponding characters differ or until the end of the strings is reached. The comparison is not case sensitive. It returns a value (< 0, 0, or > 0) based on the result of... more | |
Header File string.h, mbstring.h Category Conversion Routines, Memory and String Manipulation Routines Prototype char *strlwr(char *s); wchar_t *_wcslwr(wchar_t *s); unsigned char *_mbslwr(unsigned char *s); Description Converts uppercase letters in a string to lowercase. strlwr converts uppercase letters in string s to lowercase according to the current locale's LC_CTYPE category. For the C locale, the conversion is from uppercase letters (A to Z) to lowercase letters (a to z). No other characters are changed. Return Value strlwr returns a pointer to the string s. Example | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines, Inline Routines Prototype char *strncat(char *dest, const char *src, size_t maxlen); wchar_t *wcsncat(wchar_t *dest, const wchar_t *src, size_t maxlen); unsigned char *_mbsncat(unsigned char *dest, const unsigned char *src, size_t maxlen); unsigned char *_mbsnbcat(unsigned char *__dest, const unsigned char *__src, _SIZE_T __maxlen); Description Appends a portion of one string to another. strncat copies at most maxlen characters of src to the end of dest and then appends a null character. The maximum length of the resulting string is strlen(dest) + maxlen. For _mbsnbcat, if the second byte of 2-bytes character is... more | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines, Inline Routines Prototype int strncmp(const char *s1, const char *s2, size_t maxlen); int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t maxlen); int _mbsncmp(const unsigned char *s1, const unsigned char *s2, size_t maxlen); #define _mbccmp(__s1, __s2) _mbsncmp((__s1),(__s2),1) Description Compares a portion of one string to a portion of another. strncmp makes the same unsigned comparison as strcmp, but looks at no more than maxlen characters. It starts with the first character in each string and continues with subsequent characters until the corresponding characters differ or until it has examined maxlen characters.... more | |
Header File string.h Category Memory and String Manipulation Routines Prototype int strncmpi(const char *s1, const char *s2, size_t n); int wcsncmpi(const wchar_t *s1, const wchar_t *s2, size_t n); Description Compares a portion of one string to a portion of another, without case sensitivity. strncmpi performs a signed comparison of s1 to s2, for a maximum length of n bytes, starting with the first character in each string and continuing with subsequent characters until the corresponding characters differ or until n characters have been examined. The comparison is not case sensitive. (strncmpi is the same as strnicmp--implemented as a macro). It... more | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines Prototype int _strncoll(const char *s1, const char *s2, size_t n); int _wcsncoll(const wchar_t *s1, const wchar_t *s2, size_t n); int _strnicoll(const char *s1, const char *s2, size_t n); int _wcsnicoll(const wchar_t *s1, const wchar_t *s2, size_t n); int _mbsncoll(const unsigned char *s1, const unsigned char *s2, size_t n); int _mbsnicoll(const unsigned char *s1, const unsigned char *s2, size_t n); Description _strncoll compares n number of elements from the string pointed to by s1 to the string pointed to by s2, according to the current locale's LC_COLLATE category. _strnicoll performs like... more | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines, Inline Routines Prototype char *strncpy(char *dest, const char *src, size_t maxlen); wchar_t *wcsncpy(wchar_t *dest, const wchar_t *src, size_t maxlen); unsigned char *_mbsncpy(unsigned char *dest, const unsigned char *src, size_t maxlen); Description Copies a given number of bytes from one string into another, truncating or padding as necessary. strncpy copies up to maxlen characters from src into dest, truncating or null-padding dest. The target string, dest, might not be null-terminated if the length of src is maxlen or more. Return Value strncpy returns dest. Example | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines Prototype int strnicmp(const char *s1, const char *s2, size_t maxlen); int _wcsnicmp(const wchar_t *s1, const wchar_t *s2, size_t maxlen); int _mbsnicmp(const unsigned char *s1, const unsigned char *s2, size_t maxlen); Description Compares a portion of one string to a portion of another, without case sensitivity. strnicmp performs a signed comparison of s1 to s2, for a maximum length of maxlen bytes, starting with the first character in each string and continuing with subsequent characters until the corresponding characters differ or until the end of the strings is reached. The comparison... more | |
Header File string.h Category Memory and String Manipulation Routines, Inline Routines Prototype char *strnset(char *s, int ch, size_t n); wchar_t *_wcsnset(wchar_t *s, wchar_t ch, size_t n); unsigned char *_mbsnset(unsigned char *s, unsigned int ch, size_t n); Description Sets a specified number of characters in a string to a given character. strnset copies the character ch into the first n bytes of the string s. If n > strlen(s), then strlen(s) replaces n. It stops when n characters have been set, or when a null character is found. Return Value Each of these functions return s. Example | |
Header File string.h, mbstring.h Category C++ Prototyped Routines, Memory and String Manipulation Routines Prototype char *strpbrk(const char *s1, const char *s2); /* C only */ const char *strpbrk(const char *s1, const char *s2); // C++ only char *strpbrk(char *s1, const char *s2); // C++ only wchar_t * wcspbrk(const wchar_t *s1, const wchar_t *s2); unsigned char *_mbspbrk(const unsigned char *s1, const unsigned char *s2); Description Scans a string for the first occurrence of any character from a given set. strpbrk scans a string, s1, for the first occurrence of any character appearing in s2. Return Value strpbrk returns a pointer to... more | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines, Inline Routines, C++ Prototyped Routines Prototype char *strrchr(const char *s, int c); /* C only */ const char *strrchr(const char *s, int c); // C++ only char *strrchr(char *s, int c); // C++ only wchar_t *wcsrchr(const wchar_t *s, wchar_t c); unsigned char * _mbsrchr(const unsigned char *s, unsigned int c); Description Scans a string for the last occurrence of a given character. strrchr scans a string in the reverse direction, looking for a specific character. strrchr finds the last occurrence of the character c in the string s. The null-terminator... more | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines Prototype char *strrev(char *s); wchar_t *_wcsrev(wchar_t *s); unsigned char *_mbsrev(unsigned char *s); Description Reverses a string. strrev changes all characters in a string to reverse order, except the terminating null character. (For example, it would change string\0 to gnirts\0.) Return Value strrev returns a pointer to the reversed string. Example | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines, Inline Routines Prototype char *strset(char *s, int ch); wchar_t *_wcsset(wchar_t *s, wchar_t ch); unsigned char *_mbsset(unsigned char *s, unsigned int ch); Description Sets all characters in a string to a given character. strset sets all characters in the string s to the character ch. It quits when the terminating null character is found. Return Value strset returns s. Example | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines Prototype size_t strspn(const char *s1, const char *s2); size_t wcsspn(const wchar_t *s1, const wchar_t *s2); size_t _mbsspn(const unsigned char *s1, const unsigned char *s2); Description Scans a string for the first segment that is a subset of a given set of characters. strspn finds the initial segment of string s1 that consists entirely of characters from string s2. Return Value strspn returns the length of the initial segment of s1 that consists entirely of characters from s2. Example | |
Header File string.h Category C++ Prototyped Routines, Memory and String Manipulation Routines Prototype char *strstr(const char *s1, const char *s2); /* C only */ const char *strstr(const char *s1, const char *s2); // C++ only char *strstr(char *s1, const char *s2); // C++ only wchar_t * wcsstr(const wchar_t *s1, const wchar_t *s2); unsigned char * _mbsstr(const unsigned char *s1, const unsigned char *s2); Description Scans a string for the occurrence of a given substring. strstr scans s1 for the first occurrence of the substring s2. Return Value strstr returns a pointer to the element in s1, where s2 begins (points... more | |
Header File string.h, mbstring.h Category Memory and String Manipulation Routines Prototype char *strtok(char *s1, const char *s2); wchar_t *wcstok(wchar_t *s1, const wchar_t *s2); unsigned char *_mbstok(unsigned char *s1, const unsigned char *s2); Description Searches one string for tokens, which are separated by delimiters defined in a second string. strtok considers the string s1 to consist of a sequence of zero or more text tokens, separated by spans of one or more characters from the separator string s2. The first call to strtok returns a pointer to the first character of the first token in s1 and writes a null character... more | |
Header File string.h, mbstring.h Category Conversion Routines, Memory and String Manipulation Routines Prototype char *strupr(char *s); wchar_t *_wcsupr(wchar_t *s); unsigned char *_mbsupr(unsigned char *s); Description Converts lowercase letters in a string to uppercase. strupr converts lowercase letters in string s to uppercase according to the current locale's LC_CTYPE category. For the default C locale, the conversion is from lowercase letters (a to z) to uppercase letters (A to Z). No other characters are changed. Return Value strupr returns s. Example | |
Header File string.h Category Memory and String Manipulation Routines Prototype size_t strxfrm(char *target, const char *source, size_t n); size_t wcsxfrm(wchar_t *target, const wchar_t *source, size_t n); Description Transforms a portion of a string to a specified collation. strxfrm transforms the string pointed to by source into the string target for no more than n characters. The transformation is such that if the strcmp function is applied to the resulting strings, its return corresponds with the return values of the strcoll function. No more than n characters, including the terminating null character, are copied to target. strxfrm transforms a character string... more |
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|