c/string/byte: Difference between revisions
From cppreference.com
m Shorten template names. Use {{lc}} where appropriate. |
m Update links. |
||
| Line 8: | Line 8: | ||
{{dsc h2 | Character classification}} | {{dsc h2 | Character classification}} | ||
{{dsc header | ctype.h}} | {{dsc header | ctype.h}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/isalnum}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/isalpha}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/islower}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/isupper}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/isdigit}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/isxdigit}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/iscntrl}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/isgraph}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/isspace}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/isblank}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/isprint}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/ispunct}} | ||
{{dsc h2 | Character manipulation}} | {{dsc h2 | Character manipulation}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/tolower}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/toupper}} | ||
{{dsc end}} | {{dsc end}} | ||
{{c/string/character classes}} | {{c/string/character classes}} | ||
| Line 30: | Line 30: | ||
{{dsc h2 | Conversions to numeric formats}} | {{dsc h2 | Conversions to numeric formats}} | ||
{{dsc header | stdlib.h}} | {{dsc header | stdlib.h}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/atof}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/atoi}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strtol}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strtoul}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strtof}} | ||
{{dsc header | inttypes.h}} | {{dsc header | inttypes.h}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strtoimax}} | ||
{{dsc h2 | String manipulation}} | {{dsc h2 | String manipulation}} | ||
{{dsc header | string.h}} | {{dsc header | string.h}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strcpy}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strncpy}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strcat}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strncat}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strxfrm}} | ||
{{dsc h2 | String examination}} | {{dsc h2 | String examination}} | ||
{{dsc header | string.h}} | {{dsc header | string.h}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strlen}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strcmp}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strncmp}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strcoll}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strchr}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strrchr}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strspn}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strcspn}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strpbrk}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strstr}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strtok}} | ||
{{dsc h2 | Character array manipulation}} | {{dsc h2 | Character array manipulation}} | ||
{{dsc header | string.h}} | {{dsc header | string.h}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/memchr}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/memcmp}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/memset}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/memcpy}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/memmove}} | ||
{{dsc h2 | Miscellaneous}} | {{dsc h2 | Miscellaneous}} | ||
{{dsc header | string.h}} | {{dsc header | string.h}} | ||
{{dsc inc | c/string/byte/ | {{dsc inc | c/string/byte/strerror}} | ||
{{dsc end}} | {{dsc end}} | ||
Revision as of 05:40, 1 June 2013
A null-terminated byte string (NTBS) is a sequence of nonzero bytes followed by a byte with value zero (the terminating null character). Each byte in a byte string encodes one character of some character set. For example, the character array {'\x63','\x61','\x74','\0'} is an NTBS holding the string "cat" in ASCII encoding.
Functions
Character classification | |
Defined in header
<ctype.h> | |
| checks if a character is alphanumeric (function) | |
| checks if a character is alphabetic (function) | |
| checks if a character is lowercase (function) | |
| checks if a character is an uppercase character (function) | |
| checks if a character is a digit (function) | |
| checks if a character is a hexadecimal character (function) | |
| checks if a character is a control character (function) | |
| checks if a character is a graphical character (function) | |
| checks if a character is a space character (function) | |
(C99) |
checks if a character is a blank character (function) |
| checks if a character is a printing character (function) | |
| checks if a character is a punctuation character (function) | |
Character manipulation | |
| converts a character to lowercase (function) | |
| converts a character to uppercase (function) | |
| ASCII values | characters | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| decimal | hexadecimal | octal | |||||||||||||
| 0–8 | \x0–\x8
|
\0–\10
|
control codes (NUL, etc.)
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 9 | \x9
|
\11
|
tab (\t)
|
≠0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 10–13 | \xA–\xD
|
\12–\15
|
whitespaces (\n, \v, \f, \r)
|
≠0
|
0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 14–31 | \xE–\x1F
|
\16–\37
|
control codes | ≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 32 | \x20
|
\40
|
space | 0
|
≠0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 33–47 | \x21–\x2F
|
\41–\57
|
!"#$%&'()*+,-./
|
0
|
≠0
|
0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 48–57 | \x30–\x39
|
\60–\71
|
0123456789
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
0
|
0
|
0
|
≠0
|
≠0
|
| 58–64 | \x3A–\x40
|
\72–\100
|
:;<=>?@
|
0
|
≠0
|
0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 65–70 | \x41–\x46
|
\101–\106
|
ABCDEF
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
≠0
|
≠0
|
0
|
0
|
≠0
|
| 71–90 | \x47–\x5A
|
\107–\132
|
GHIJKLMNOPQRSTUVWXYZ
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
≠0
|
≠0
|
0
|
0
|
0
|
| 91–96 | \x5B–\x60
|
\133–\140
|
[\]^_`
|
0
|
≠0
|
0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 97–102 | \x61–\x66
|
\141–\146
|
abcdef
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
≠0
|
0
|
≠0
|
0
|
≠0
|
| 103–122 | \x67–\x7A
|
\147–\172
|
ghijklmnopqrstuvwxyz
|
0
|
≠0
|
0
|
0
|
≠0
|
0
|
≠0
|
≠0
|
0
|
≠0
|
0
|
0
|
| 123–126 | \x7B–\x7E
|
\173–\176
|
{|}~
|
0
|
≠0
|
0
|
0
|
≠0
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
| 127 | \x7F
|
\177
|
backspace character (DEL)
|
≠0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
Conversions to numeric formats | |
Defined in header
<stdlib.h> | |
| converts a byte string to a floating-point value (function) | |
(C99) |
converts a byte string to an integer value (function) |
(C99) |
converts a byte string to an integer value (function) |
(C99) |
converts a byte string to an unsigned integer value (function) |
(C99)(C99) |
converts a byte string to a floating-point value (function) |
Defined in header
<inttypes.h> | |
(C99)(C99) |
converts a byte string to intmax_t or uintmax_t (function) |
String manipulation | |
Defined in header
<string.h> | |
(C11) |
copies one string to another (function) |
(C11) |
copies a certain amount of characters from one string to another (function) |
(C11) |
concatenates two strings (function) |
(C11) |
concatenates a certain amount of characters of two strings (function) |
| transform a string so that strcmp would produce the same result as strcoll (function) | |
String examination | |
Defined in header
<string.h> | |
(C11) |
returns the length of a given string (function) |
| compares two strings (function) | |
| compares a certain amount of characters of two strings (function) | |
| compares two strings in accordance to the current locale (function) | |
| finds the first occurrence of a character (function) | |
| finds the last occurrence of a character (function) | |
| returns the length of the maximum initial segment that consists of only the characters found in another byte string (function) | |
| returns the length of the maximum initial segment that consists of only the characters not found in another byte string (function) | |
| finds the first location of any character in one string, in another string (function) | |
| finds the first occurrence of a substring of characters (function) | |
(C11) |
finds the next token in a byte string (function) |
Character array manipulation | |
Defined in header
<string.h> | |
| searches an array for the first occurrence of a character (function) | |
| compares two buffers (function) | |
(C23)(C11) |
fills a buffer with a character (function) |
(C11) |
copies one buffer to another (function) |
(C11) |
moves one buffer to another (function) |
Miscellaneous | |
Defined in header
<string.h> | |
(C11)(C11) |
returns a text version of a given error code (function) |