Char and wchar processing functions

Source: Internet
Author: User
Tags uppercase character

 

Using atoi made me very uncomfortable, so I found this information online, formerly known as the <char and tchar processing functions>. I thought the title was incorrect and changed tchar to wchar.

Character classification: Description of common C functions of wide character Functions

Iswalnum () isalnum () test whether the character is a number or letter

Iswalpha () isalpha () test whether the character is a letter

Iswcntrl () iscntrl () test whether the character is a controller

Iswdigit () isdigit () test whether the character is a number

Iswgraph () isgraph () test whether the character is visible

Iswlower () islower () test whether the character is a lowercase character

Iswprint () isprint () test whether the character is printable

Iswpunct () ispunct () test whether the character is a punctuation mark

Iswspace () isspace () test whether the character is a blank sign

Iswupper () isupper () test whether the character is an uppercase character

Iswxdigit () isxdigit () test whether the character is a hexadecimal number

Case sensitivity conversion:

Description of common C functions of wide character Functions

Towlower () tolower () converts characters to lowercase letters

Towupper () toupper () converts the character to uppercase

Character comparison: Description of common C functions of wide character Functions

Wcscoll () strcoll () Comparison string

Date and Time conversion:

Wide character Function Description

Strftime () sets the format date and time based on the specified string format and locale

Wcsftime () sets the format date and time based on the specified string format and locale, and returns the wide string

Strptime () converts a string to a time value based on the specified format, which is the reverse process of strftime.

Print and scan strings:

Wide character Function Description

Fprintf ()/fwprintf () format the output using the vararg Parameter

Fscanf ()/fwscanf () format read

Printf () uses the vararg parameter to format the output to the standard output.

Scanf () reads formatted data from standard input

Sprintf ()/swprintf () formatted as a string based on the vararg parameter table

Sscanf () is formatted and read as a string

Vfprintf ()/vfwprintf () format the output to a file using the stdarg parameter table

Vprintf () uses the stdarg parameter table to format the output to the standard output.

Vsprintf ()/vswprintf () format the stdarg parameter table and write it to the string

Digital Conversion:

Description of common C functions of wide character Functions

Wcstod () strtodd () converts the initial part of a wide character to a double-precision floating point number.

Wcstol () strtol () converts the initial part of a wide character to a long integer.

Wcstoul () strtoul () converts the initial part of a wide character to an unsigned long integer.

Multi-Byte Character and wide character conversion and operations:

Wide character Function Description

Mblen () determines the number of characters in bytes based on locale settings

Mbstowcs () converts a multi-byte string to a wide string.

Mbtowc ()/btowc () converts multi-byte characters into wide characters

Wcstombs () converts a wide string to a multi-byte string.

Wctomb ()/wctob () converts a wide character to a multi-Byte Character

Input and Output:

Description of common C functions of wide character Functions

Fgetwc () fgetc () reads a character from the stream and converts it to a wide character.

Fgetws () fgets () reads a string from the stream and converts it to a wide string.

Fputwc () fputc () converts wide characters into multi-byte characters and outputs them to standard output.

Fputws () fputs () converts a wide string into multiple bytes and outputs the string to the standard output string.

Getwc () GETC () reads characters from the standard input and converts them to wide characters.

Getwchar () getchar () reads characters from the standard input and converts them to wide characters.

None gets () Use fgetws ()

Putwc () putc () converts a wide character into a multi-Byte Character and writes it to the standard output.

Putwchar () putchar () converts a wide character into a multi-Byte Character and writes it to the standard output.

None puts () Use fputws ()

Ungetwc () ungetc () places a wide character in the input stream

String operation:

Description of common C functions of wide character Functions

Wcscat () strcat () concatenates a string to the end of another string

Wcsncat () strncat () is similar to wcscat () and specifies the bond length of the bond string.

Wcschr () strchr () finds the first position of the substring

Wcsrchr () strrchr () searches for the first position of the substring from the tail.

Wcspbrk () strpbrk () Searches from the character string for the first occurrence of any character in the other string

Wcswcs ()/wcsstr () strchr () searches for the first occurrence location of another string in one string

Returns the initial number of records that do not contain the second string.

Wcsspns () strspns () returns the initial number of strings containing the second string.

Wcscpy () strcpy () Copy string

Wcsncpy () strncpy () is similar to wcscpy () and specifies the number of copies.

Wcscmp () strcmp () compares two wide strings

Wcsncmp () strncmp () is similar to wcscmp () and also specifies the number of character strings to be compared.

Wcslen () strlen () gets the number of wide strings

Wcstok () strtok () Splits a wide string into a series of strings Based on the identifier

Wcswidth () None to get the width of the wide string

Wcwidth () None

In addition, wmemcpy (), wmemchr (), wmemcmp (), wmemmove (), and wmemset () for memory operations ().

Finally, add two useful macros ~

# Define a2w (LPA )(\

(_ LPA = LPA) = NULL )? Null :(\

_ Convert = (lstrlena (_ LPA) + 1 ),\

(Int_max/2 <_ convert )? Null :\

Atla2whelper (lpwstr) alloca (_ convert * sizeof (wchar), _ LPA, _ convert, _ ACP )))

# Define w2a (lpw )(\

(_ Lpw = lpw) = NULL )? Null :(\

(_ Convert = (lstrlenw (_ lpw) + 1 ),\

(_ Convert> int_max/2 )? Null :\

Atlw2ahelper (lpstr) alloca (_ convert * sizeof (wchar), _ lpw, _ convert * sizeof (wchar), _ ACP ))))

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.