松鼠吃什么| 异卵双胞胎什么意思| 绿豆汤放什么糖| 阳痿吃什么药| 眼角膜脱落有什么症状| cachecache是什么牌子| 兔配什么生肖最好| 雌二醇高有什么症状| 梦见狗咬手是什么意思| 呼吸衰竭是什么意思| 夏天为什么要吃姜| 为什么医院不开金刚藤| 什么是ct| 拆线挂什么科| 小孩发育迟缓是什么原因造成的| 鼻炎吃什么药见效快| 牙齿发白是什么原因| 更年期吃什么药| 小螃蟹吃什么| 鱼油有什么作用| 什么茶适合煮着喝| 苏州秋裤楼叫什么| 内痔吃什么药| 天贝是什么东西| 1月9日什么星座| 感冒什么时候传染性最强| 鼻梁歪的男人说明什么| 6月7号什么星座| 什么是情绪| 男性性功能下降是什么原因| 心门是什么意思| cpa是什么证书| 谶语是什么意思| 转折是什么意思| 艾灸后放屁多是什么原因| 白天为什么能看到月亮| 什么网名好听| 眼肿是什么原因引起的| 梦见家里发大水了是什么征兆| 神经病吃什么药效果好| 体脂是什么| 水瓶女和什么座最配| 末次月经是什么意思| 本是同根生相煎何太急是什么意思| 芒果有什么好处| 子宫息肉是什么| 阴道炎什么症状| 25年是什么婚| pd是什么金属| 金翅鸟吃什么| 明天是什么日子| 掉头发吃什么药最有效| joeone是什么牌子| 什么情况下做心脏造影| 什么动物寿命最短| 脾肾阳虚吃什么中成药| 莓茶属于什么茶| 六月十号什么星座| 焦虑症是什么| 西元前是什么意思| 九十岁老人称什么| 乳腺囊肿和乳腺结节有什么区别| 三月十五日是什么星座| 乳房头疼是什么原因| 肝裂不宽是什么意思| 什么是性冷淡| 清明节一般开什么生肖| 肝结节是什么病严重吗| 蕙字五行属什么| 唾液酸苷酶阳性是什么意思| 腰椎间盘突出吃什么药| 人为什么会得甲母痣| 讨厌是什么意思| 蜂蜜变质是什么样子| 拜戈手表属于什么档次| 外阴瘙痒用什么洗液| 侧睡流口水是什么原因| 调御丈夫是什么意思| 低聚木糖是什么| 水当当是什么意思| 护理专业出来能干什么| bliss是什么意思| 老想睡觉是什么原因| 什么是麦粒肿| a型rhd阳性是什么意思| 大暑吃什么| 指导员是什么级别| 拔智齿后要注意什么| 胆固醇高是什么病| 迪士尼狗狗叫什么名字| 男人更年期有什么症状有哪些表现| 象牙有什么作用与功效| 感冒嗓子哑了吃什么药| 什么叫牙冠| 玉米吃多了有什么坏处| 殚精竭虑什么意思| 公仆是什么意思| 什么病不能吃绿豆| 爱生气的人容易得什么病| 肚子胀不消化吃什么药| 12580是什么号码| 心什么如什么的成语| 红豆不能和什么一起吃| ed2k用什么下载| 长期胃胀气什么原因| 孕妇脚肿是什么原因| 感情里什么叫偏爱| 家里镜子放在什么位置比较好| 五级士官是什么级别| faleda是什么牌子的手表| kid是什么意思| 黄瓜敷脸有什么功效与作用| 裹腹是什么意思| 晒太阳补什么| 什么是梅尼埃病| 1922年属什么生肖| 四叶草的寓意是什么| 尿酸高适合吃什么水果| 呆呆的笑是什么笑| 分割线是什么意思| 乙肝小三阳是什么意思| 攀龙附凤是什么生肖| champion什么意思| 夏天喝什么饮料好| 流眼泪是什么原因| 高血糖吃什么比较好| 寻麻疹是什么原因引起的| 猪肝能钓什么鱼| 头痒是什么原因| 血红蛋白高是什么意思| 西晋之后是什么朝代| 两个土念什么字| 什么人容易得焦虑症| ut是什么意思| 日加个成念什么| 笑面虎什么意思| 一什么冰箱| 胸有成竹什么意思| 月经第二天属于什么期| 喰种是什么意思| 为什么老是便秘| 七夕节的含义是什么| 什么车可以闯红灯| 善茬是什么意思| 浪琴名匠系列什么档次| 英寸是什么单位| 什么是白脉病| mc什么意思| 627是什么星座| 女人什么血型最聪明| 什么睡姿可以矫正驼背| 后脖子黑是什么原因| 复方乙酰水杨酸片是什么药| 女生喜欢什么| 排卵试纸什么时候测最准确| 哈比是什么意思| 腰椎间盘突出和膨出有什么区别| 肺不好挂什么科| 月经一直不干净是什么原因| 中指麻木是什么原因引起的| 淡淡的什么| 老是嗳气是什么原因| 紫色和蓝色混合是什么颜色| 农历十月初五是什么星座| 雷锋原名叫什么| 什么颜薄命| 移植后需要注意什么| reads是什么意思| 验光挂什么科| cpi是什么| 甲状腺毒症是什么意思| 九九年属什么| 骨折后吃什么好的快| 小孩鼻子出血什么原因| 脚软没力气是什么原因引起的| 煞北是什么意思| 消防大队长是什么级别| 婴儿半夜哭闹是什么原因| 什么情况下需做肠镜| 心肌梗塞有什么症状| 单招是什么学历| 矢气是什么意思| 一什么椅子| 胎儿双顶径偏大是什么原因| 氨酚咖那敏片是什么药| 头晕是什么病的征兆| 尿淀粉酶高是什么原因| 12月17号什么星座| 脾胃虚弱吃什么中药| 申是什么意思| 心脏不好喝什么茶比较好| 杰字五行属什么| 范冰冰和洪金宝什么关系| www是什么意思| 对联又称什么| 司令是什么级别| acei是什么| 口嗨是什么意思| silk什么意思| 为什么生理期过后最容易掉秤| 人中有痣代表什么| 为什么长白头发| 清热败火的败是什么意思| 李白字什么号什么| 罗飞鱼是什么鱼| 地位是什么意思| 咳嗽消炎药吃什么好| 一什么绳子| 县政府党组成员什么级别| 4月15日是什么日子| asp是什么氨基酸| 六月五号是什么星座| 护肝吃什么药| 萎缩性胃炎不能吃什么食物| 精忠报国是什么生肖| 什么发型好看| 脑梗是什么意思| 善太息是什么意思| 七月份生日是什么星座| 葡萄糖阳性是什么意思| 全青皮是什么皮| chloe是什么牌子| 药流吃什么药| 德艺双馨是什么意思| 为什么一分钟就出来了| 小孩过敏吃什么药| 坐镇是什么意思| 凉爽的什么| 充气娃娃是什么| 反胃酸是什么原因| 宫颈管分离是什么意思| 屈原是什么诗人| 体寒吃什么好| 什么是膝关节退行性变| 打喷嚏流鼻涕吃什么药| 田宅宫是什么意思| 一个胸大一个胸小是什么原因| 右脚踝肿是什么原因引起的| 胸围110是什么罩杯| 小腿前侧肌肉叫什么| 真露酒属于什么酒| leep是什么手术| 木全读什么| 一月九号是什么星座| 为什么微信运动总是显示步数为0| 丁目是什么意思| 杆菌是什么| 蝉联是什么意思| ash是什么牌子| 6月24日是什么日子| 鸽子和什么炖气血双补| 减肥期间可以吃什么零食| 孕酮低跟什么有关系| 脖子后面有痣代表什么| 考核是什么意思| 红眼病不能吃什么东西| 牙齿突然出血是什么原因| 尿红细胞阳性什么意思| 熬粥用什么锅好| 摩羯前面是什么星座| ghost是什么意思| 明天是什么生肖| 夜尿频多吃什么药效果好| 战五渣是什么意思| 百度Jump to content

第二届河北省旅游产业发展大会开幕式暨旅游文化推介会

From Wikipedia, the free encyclopedia
(Redirected from String.h)
百度 预计2018年,在中国江苏下水首航,驶向有钱人的天堂-。

The C programming language has a set of functions implementing operations on strings (character strings and byte strings) in its standard library. Various operations, such as copying, concatenation, tokenization and searching are supported. For character strings, the standard library uses the convention that strings are null-terminated: a string of n characters is represented as an array of n + 1 elements, the last of which is a "NUL character" with numeric value 0.

The only support for strings in the programming language proper is that the compiler translates quoted string constants into null-terminated strings.

Definitions

[edit]

A string is defined as a contiguous sequence of code units terminated by the first zero code unit (often called the NUL code unit).[1] This means a string cannot contain the zero code unit, as the first one seen marks the end of the string. The length of a string is the number of code units before the zero code unit.[1] The memory occupied by a string is always one more code unit than the length, as space is needed to store the zero terminator.

Generally, the term string means a string where the code unit is of type char, which is exactly 8 bits on all modern machines. C90 defines wide strings[1] which use a code unit of type wchar_t, which is 16 or 32 bits on modern machines. This was intended for Unicode but it is increasingly common to use UTF-8 in normal strings for Unicode instead.

Strings are passed to functions by passing a pointer to the first code unit. Since char * and wchar_t * are different types, the functions that process wide strings are different than the ones processing normal strings and have different names.

String literals ("text" in the C source code) are converted to arrays during compilation.[2] The result is an array of code units containing all the characters plus a trailing zero code unit. In C90 L"text" produces a wide string. A string literal can contain the zero code unit (one way is to put \0 into the source), but this will cause the string to end at that point. The rest of the literal will be placed in memory (with another zero code unit added to the end) but it is impossible to know those code units were translated from the string literal, therefore such source code is not a string literal.[3]

Character encodings

[edit]

Each string ends at the first occurrence of the zero code unit of the appropriate kind (char or wchar_t). Consequently, a byte string (char*) can contain non-NUL characters in ASCII or any ASCII extension, but not characters in encodings such as UTF-16 (even though a 16-bit code unit might be nonzero, its high or low byte might be zero). The encodings that can be stored in wide strings are defined by the width of wchar_t. In most implementations, wchar_t is at least 16 bits, and so all 16-bit encodings, such as UCS-2, can be stored. If wchar_t is 32-bits, then 32-bit encodings, such as UTF-32, can be stored. (The standard requires a "type that holds any wide character", which on Windows no longer holds true since the UCS-2 to UTF-16 shift. This was recognized as a defect in the standard and fixed in C++.)[4] C++11 and C11 add two types with explicit widths char16_t and char32_t.[5]

Variable-width encodings can be used in both byte strings and wide strings. String length and offsets are measured in bytes or wchar_t, not in "characters", which can be confusing to beginning programmers. UTF-8 and Shift JIS are often used in C byte strings, while UTF-16 is often used in C wide strings when wchar_t is 16 bits. Truncating strings with variable-width characters using functions like strncpy can produce invalid sequences at the end of the string. This can be unsafe if the truncated parts are interpreted by code that assumes the input is valid.

Support for Unicode literals such as char foo[512] = "φωωβαρ"; (UTF-8) or wchar_t foo[512] = L"φωωβαρ"; (UTF-16 or UTF-32, depends on wchar_t) is implementation defined,[6] and may require that the source code be in the same encoding, especially for char where compilers might just copy whatever is between the quotes. Some compilers or editors will require entering all non-ASCII characters as \xNN sequences for each byte of UTF-8, and/or \uNNNN for each word of UTF-16. Since C11 (and C++11), a new literal prefix u8 is available that guarantees UTF-8 for a bytestring literal, as in char foo[512] = u8"φωωβαρ";.[7] Since C++20 and C23, a char8_t type was added that is meant to store UTF-8 characters and the types of u8 prefixed character and string literals were changed to char8_t and char8_t[] respectively.

Features

[edit]

Terminology

[edit]

In historical documentation the term "character" was often used instead of "byte" for C strings, which leads many[who?] to believe that these functions somehow do not work for UTF-8. In fact all lengths are defined as being in bytes and this is true in all implementations, and these functions work as well with UTF-8 as with single-byte encodings. The BSD documentation has been fixed to make this clear, but POSIX, Linux, and Windows documentation still uses "character" in many places where "byte" or "wchar_t" is the correct term.

Functions for handling memory buffers can process sequences of bytes that include null-byte as part of the data. Names of these functions typically start with mem, as opposite to the str prefix.

Headers

[edit]

Most of the functions that operate on C strings are declared in the string.h header (cstring in C++), while functions that operate on C wide strings are declared in the wchar.h header (cwchar in C++). These headers also contain declarations of functions used for handling memory buffers; the name is thus something of a misnomer.

Functions declared in string.h are extremely popular since, as a part of the C standard library, they are guaranteed to work on any platform which supports C. However, some security issues exist with these functions, such as potential buffer overflows when not used carefully and properly, causing the programmers to prefer safer and possibly less portable variants, out of which some popular ones are listed below. Some of these functions also violate const-correctness by accepting a const string pointer and returning a non-const pointer within the string. To correct this, some have been separated into two overloaded functions in the C++ version of the standard library.

Constants and types

[edit]
Name Notes
NULL Macro expanding to the null pointer constant; that is, a constant representing a pointer value which is guaranteed not to be a valid address of an object in memory.
wchar_t Type used for a code unit in "wide" strings. On Windows, the only platform to use wchar_t extensively, it's defined as 16-bit[8] which was enough to represent any Unicode (UCS-2) character, but is now only enough to represent a UTF-16 code unit, which can be half a code point. On other platforms it is defined as 32-bit and a Unicode code point always fits. The C standard only requires that wchar_t be wide enough to hold the widest character set among the supported system locales[9] and be greater or equal in size to char,[10]
wint_t Integer type that can hold any value of a wchar_t as well as the value of the macro WEOF. This type is unchanged by integral promotions. Usually a 32 bit signed value.
char8_t[11] Part of the C standard since C23, in <uchar.h>, a type that is suitable for storing UTF-8 characters.[12]
char16_t[13] Part of the C standard since C11,[14] in <uchar.h>, a type capable of holding 16 bits even if wchar_t is another size. If the macro __STDC_UTF_16__ is defined as 1, the type is used for UTF-16 on that system. This is always the case in C23.[15] C++ does not define such a macro, but the type is always used for UTF-16 in that language.[16]
char32_t[13] Part of the C standard since C11,[17] in <uchar.h>, a type capable of holding 32 bits even if wchar_t is another size. If the macro __STDC_UTF_32__ is defined as 1, the type is used for UTF-32 on that system. This is always the case in C23.[15] C++ does not define such a macro, but the type is always used for UTF-32 in that language.[16]
mbstate_t Contains all the information about the conversion state required from one call to a function to the other.

Functions

[edit]
Byte
string
Wide
string
Description[note 1]
String
manipulation
strcpy[18] wcscpy[19] Copies one string to another
strncpy[20] wcsncpy[21] Writes exactly n bytes, copying from source or adding nulls
strcat[22] wcscat[23] Appends one string to another
strncat[24] wcsncat[25] Appends no more than n bytes from one string to another
strxfrm[26] wcsxfrm[27] Transforms a string according to the current locale
String
examination
strlen[28] wcslen[29] Returns the length of the string
strcmp[30] wcscmp[31] Compares two strings (three-way comparison)
strncmp[32] wcsncmp[33] Compares a specific number of bytes in two strings
strcoll[34] wcscoll[35] Compares two strings according to the current locale
strchr[36] wcschr[37] Finds the first occurrence of a byte in a string
strrchr[38] wcsrchr[39] Finds the last occurrence of a byte in a string
strspn[40] wcsspn[41] Returns the number of initial bytes in a string that are in a second string
strcspn[42] wcscspn[43] Returns the number of initial bytes in a string that are not in a second string
strpbrk[44] wcspbrk[45] Finds in a string the first occurrence of a byte in a set
strstr[46] wcsstr[47] Finds the first occurrence of a substring in a string
strtok[48] wcstok[49] Splits a string into tokens
Miscellaneous strerror[50] Returns a string containing a message derived from an error code
Memory
manipulation
memset[51] wmemset[52] Fills a buffer with a repeated byte. Since C23, memset_explicit() was added to erase sensitive data.
memcpy[53] wmemcpy[54] Copies one buffer to another. Since C23, memccpy() was added to efficiently concatenate strings.
memmove[55] wmemmove[56] Copies one buffer to another, possibly overlapping, buffer
memcmp[57] wmemcmp[58] Compares two buffers (three-way comparison)
memchr[59] wmemchr[60] Finds the first occurrence of a byte in a buffer
  1. ^ For wide string functions substitute wchar_t for "byte" in the description

Multibyte functions

[edit]
Name Description
mblen[61] Returns the number of bytes in the next multibyte character
mbtowc[62] Converts the next multibyte character to a wide character
wctomb[63] Converts a wide character to its multibyte representation
mbstowcs[64] Converts a multibyte string to a wide string
wcstombs[65] Converts a wide string to a multibyte string
btowc[66] Converts a single-byte character to wide character, if possible
wctob[67] Converts a wide character to a single-byte character, if possible
mbsinit[68] Checks if a state object represents initial state
mbrlen[69] Returns the number of bytes in the next multibyte character, given state
mbrtowc[70] Converts the next multibyte character to a wide character, given state
wcrtomb[71] Converts a wide character to its multibyte representation, given state
mbsrtowcs[72] Converts a multibyte string to a wide string, given state
wcsrtombs[73] Converts a wide string to a multibyte string, given state
mbrtoc8[74] Converts the next multibyte character to a UTF-8 character, given state
c8rtomb[75] Converts a single code point from UTF-8 to a narrow multibyte character representation, given state
mbrtoc16[76] Converts the next multibyte character to a UTF-16 character, given state
c16rtomb[77] Converts a single code point from UTF-16 to a narrow multibyte character representation, given state
mbrtoc32[78] Converts the next multibyte character to a UTF-32 character, given state
c32rtomb[79] Converts a single code point from UTF-32 to a narrow multibyte character representation, given state

These functions all need a mbstate_t object, originally in static memory (making the functions not be thread-safe) and in later additions the caller must maintain. This was originally intended to track shift states in the mb encodings, but modern ones such as UTF-8 do not need this. However these functions were designed on the assumption that the wc encoding is not a variable-width encoding and thus are designed to deal with exactly one wchar_t at a time, passing it by value rather than using a string pointer. As UTF-16 is a variable-width encoding, the mbstate_t has been reused to keep track of surrogate pairs in the wide encoding, though the caller must still detect and call mbtowc twice for a single character.[80][81][82] Later additions to the standard admit that the only conversion programmers are interested in is between UTF-8 and UTF-16 and directly provide this.

Numeric conversions

[edit]
Byte
string
Wide
string
Description[note 1]
atof[83] converts a string to a floating-point value ('atof' means 'ASCII to float')
atoi
atol
atoll[84]
converts a string to an integer (C99) ('atoi' means 'ASCII to integer')
strtof (C99)[85]
strtod[86]
strtold (C99)[87]
wcstof (C99)[88]
wcstod[89]
wcstold (C99)[90]
converts a string to a floating-point value
strtol
strtoll[91]
wcstol
wcstoll[92]
converts a string to a signed integer
strtoul
strtoull[93]
wcstoul
wcstoull[94]
converts a string to an unsigned integer
  1. ^ Here string refers either to byte string or wide string

The C standard library contains several functions for numeric conversions. The functions that deal with byte strings are defined in the stdlib.h header (cstdlib header in C++). The functions that deal with wide strings are defined in the wchar.h header (cwchar header in C++).

The functions strchr, bsearch, strpbrk, strrchr, strstr, memchr and their wide counterparts are not const-correct, since they accept a const string pointer and return a non-const pointer within the string. This has been fixed in C23.[95]

Also, since the Normative Amendment 1 (C95), atoxx functions are considered subsumed by strtoxxx functions, for which reason neither C95 nor any later standard provides wide-character versions of these functions. The argument against atoxx is that they do not differentiate between an error and a 0.[96]

[edit]
Name Source Description
bzero[97][98] BSD Fills a buffer with zero bytes, deprecated by memset
memccpy[99] SVID Part of the C standard since C23, copies between two non-overlapping memory areas, stopping when a given byte is found.
mempcpy[100] GNU a variant of memcpy returning a pointer to the byte following the last written byte
strcasecmp[101] BSD case-insensitive version of strcmp
strcat_s[102] Windows a variant of strcat that checks the destination buffer size before copying
strcpy_s[103] Windows a variant of strcpy that checks the destination buffer size before copying
strdup & strndup[104] POSIX Part of the C standard since C23, allocates and duplicates a string
strerror_r[105] POSIX 1, GNU a variant of strerror that is thread-safe. The GNU version is incompatible with the POSIX one.
stricmp[106] Windows case-insensitive version of strcmp
strlcpy[107] BSD a variant of strcpy that truncates the result to fit in the destination buffer[108]
strlcat[107] BSD a variant of strcat that truncates the result to fit in the destination buffer[108]
strsignal[109] POSIX:2008 returns string representation of a signal code. Not thread safe.
strtok_r[110] POSIX a variant of strtok that is thread-safe

Replacements

[edit]

Despite the well-established need to replace strcat[22] and strcpy[18] with functions that do not allow buffer overflows, no accepted standard has arisen. This is partly due to the mistaken belief by many C programmers that strncat and strncpy have the desired behavior; however, neither function was designed for this (they were intended to manipulate null-padded fixed-size string buffers, a data format less commonly used in modern software), and the behavior and arguments are non-intuitive and often written incorrectly even by expert programmers.[108]

The most popular[a] replacement are the strlcat[111] and strlcpy[112] functions, which appeared in OpenBSD 2.4 in December, 1998.[108] These functions always write one NUL to the destination buffer, truncating the result if necessary, and return the size of buffer that would be needed, which allows detection of the truncation and provides a size for creating a new buffer that will not truncate. For a long time they have not been included in the GNU C library (used by software on Linux), on the basis of allegedly being inefficient,[113] encouraging the use of C strings (instead of some superior alternative form of string),[114][115] and hiding other potential errors.[116][117] Even while glibc hadn't added support, strlcat and strlcpy have been implemented in a number of other C libraries including ones for OpenBSD, FreeBSD, NetBSD, Solaris, OS X, and QNX, as well as in alternative C libraries for Linux, such as libbsd, introduced in 2008,[118] and musl, introduced in 2011,[119][120] and the source code added directly to other projects such as SDL, GLib, ffmpeg, rsync, and even internally in the Linux kernel. This did change in 2024, the glibc FAQ notes that as of glibc 2.38, the code has been committed [121] and thereby added.[122] These functions were standardized as part of POSIX.1-2024,[123] the Austin Group Defect Tracker ID 986 tracked some discussion about such plans for POSIX.

Sometimes memcpy[53] or memmove[55] are used, as they may be more efficient than strcpy as they do not repeatedly check for NUL (this is less true on modern processors). Since they need a buffer length as a parameter, correct setting of this parameter can avoid buffer overflows.

As part of its 2004 Security Development Lifecycle, Microsoft introduced a family of "secure" functions including strcpy_s and strcat_s (along with many others).[124] These functions were standardized with some minor changes as part of the optional C11 (Annex K) proposed by ISO/IEC WDTR 24731.[125] These functions perform various checks including whether the string is too long to fit in the buffer. If the checks fail, a user-specified "runtime-constraint handler" function is called,[126] which usually aborts the program.[127][128] These functions attracted considerable criticism because initially they were implemented only on Windows and at the same time warning messages started to be produced by Microsoft Visual C++ suggesting use of these functions instead of standard ones. This has been speculated by some to be an attempt by Microsoft to lock developers into its platform.[129] Experience with these functions has shown significant problems with their adoption and errors in usage, so the removal of Annex K was proposed for the next revision of the C standard.[130] Usage of memset_s has been suggested as a way to avoid unwanted compiler optimizations.[131][132]

See also

[edit]

Notes

[edit]
  1. ^ On GitHub, there are 7,813,206 uses of strlcpy, versus 38,644 uses of strcpy_s (and 15,286,150 uses of strcpy).[citation needed]

References

[edit]
  1. ^ a b c "The C99 standard draft + TC3" (PDF). §7.1.1p1. Retrieved 7 January 2011.{{cite web}}: CS1 maint: location (link)
  2. ^ "The C99 standard draft + TC3" (PDF). §6.4.5p7. Retrieved 7 January 2011.{{cite web}}: CS1 maint: location (link)
  3. ^ "The C99 standard draft + TC3" (PDF). Section 6.4.5 footnote 66. Retrieved 7 January 2011.{{cite web}}: CS1 maint: location (link)
  4. ^ "Relax requirements on wchar_t to match existing practices" (PDF).
  5. ^ "Fundamental types". en.cppreference.com.
  6. ^ "The C99 standard draft + TC3" (PDF). §5.1.1.2 Translation phases, p1. Retrieved 23 December 2011.{{cite web}}: CS1 maint: location (link)
  7. ^ "string literals". en.cppreference.com. Retrieved 23 December 2019.
  8. ^ "c++ - What is the use of wchar_t in general programming?". Stack Overflow. Retrieved 1 August 2022.
  9. ^ "stddef.h - standard type definitions". The Open Group. Retrieved 28 January 2017.
  10. ^ Gillam, Richard (2003). Unicode Demystified: A Practical Programmer's Guide to the Encoding Standard. Addison-Wesley Professional. p. 714. ISBN 9780201700527.
  11. ^ "char, wchar_t, char8_t, char16_t, char32_t". docs.microsoft.com. Retrieved 1 August 2022.
  12. ^ "char8_t".
  13. ^ a b "<cuchar> (uchar.h)".
  14. ^ "char16_t".
  15. ^ a b "Replacing text macros".
  16. ^ a b "Fundamental types".
  17. ^ "char32_t".
  18. ^ a b "strcpy - cppreference.com". En.cppreference.com. 2 January 2014. Retrieved 6 March 2014.
  19. ^ "wcscpy - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  20. ^ "strncpy - cppreference.com". En.cppreference.com. 4 October 2013. Retrieved 6 March 2014.
  21. ^ "wcsncpy - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  22. ^ a b "strcat - cppreference.com". En.cppreference.com. 8 October 2013. Retrieved 6 March 2014.
  23. ^ "wcscat - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  24. ^ "strncat - cppreference.com". En.cppreference.com. 1 July 2013. Retrieved 6 March 2014.
  25. ^ "wcsncat - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  26. ^ "strxfrm - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  27. ^ "wcsxfrm - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  28. ^ "strlen - cppreference.com". En.cppreference.com. 27 December 2013. Retrieved 6 March 2014.
  29. ^ "wcslen - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  30. ^ "strcmp - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  31. ^ "wcscmp - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  32. ^ "strncmp - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  33. ^ "wcsncmp - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  34. ^ "strcoll - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  35. ^ "wcscoll - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  36. ^ "strchr - cppreference.com". En.cppreference.com. 23 February 2014. Retrieved 6 March 2014.
  37. ^ "wcschr - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  38. ^ "strrchr - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  39. ^ "wcsrchr - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  40. ^ "strspn - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  41. ^ "wcsspn - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  42. ^ "strcspn - cppreference.com". En.cppreference.com. 31 May 2013. Retrieved 6 March 2014.
  43. ^ "wcscspn - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  44. ^ "strpbrk - cppreference.com". En.cppreference.com. 31 May 2013. Retrieved 6 March 2014.
  45. ^ "wcspbrk - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  46. ^ "strstr - cppreference.com". En.cppreference.com. 16 October 2013. Retrieved 6 March 2014.
  47. ^ "wcsstr - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  48. ^ "strtok - cppreference.com". En.cppreference.com. 3 September 2013. Retrieved 6 March 2014.
  49. ^ "wcstok - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  50. ^ "strerror - cppreference.com". En.cppreference.com. 31 May 2013. Retrieved 6 March 2014.
  51. ^ "memset - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  52. ^ "wmemset - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  53. ^ a b "memcpy - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  54. ^ "wmemcpy - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  55. ^ a b "memmove - cppreference.com". En.cppreference.com. 25 January 2014. Retrieved 6 March 2014.
  56. ^ "wmemmove - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  57. ^ "memcmp - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  58. ^ "wmemcmp - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  59. ^ "memchr - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  60. ^ "wmemchr - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  61. ^ "mblen - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  62. ^ "mbtowc - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  63. ^ "wctomb - cppreference.com". En.cppreference.com. 4 February 2014. Retrieved 6 March 2014.
  64. ^ "mbstowcs - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  65. ^ "wcstombs - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  66. ^ "btowc - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  67. ^ "wctob - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  68. ^ "mbsinit - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  69. ^ "mbrlen - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  70. ^ "mbrtowc - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  71. ^ "wcrtomb - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  72. ^ "mbsrtowcs - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  73. ^ "wcsrtombs - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  74. ^ "mbrtoc8 - cppreference.com". En.cppreference.com.
  75. ^ "c8rtomb - cppreference.com". En.cppreference.com.
  76. ^ "mbrtoc16 - cppreference.com". En.cppreference.com.
  77. ^ "c16rtomb - cppreference.com". En.cppreference.com.
  78. ^ "mbrtoc32 - cppreference.com". En.cppreference.com.
  79. ^ "c23rtomb - cppreference.com". En.cppreference.com.
  80. ^ "6.3.2 Representing the state of the conversion". The GNU C Library. Retrieved 31 January 2017.
  81. ^ "root/src/multibyte/c16rtomb.c". Retrieved 31 January 2017.
  82. ^ "Contents of /stable/11/lib/libc/locale/c16rtomb.c". Retrieved 31 January 2017.
  83. ^ "atof - cppreference.com". En.cppreference.com. 31 May 2013. Retrieved 6 March 2014.
  84. ^ "atoi, atol, atoll - cppreference.com". En.cppreference.com. 18 January 2014. Retrieved 6 March 2014.
  85. ^ "strtof, strtod, strtold - cppreference.com". En.cppreference.com. 4 February 2014. Retrieved 6 March 2014.
  86. ^ "strtof, strtod, strtold - cppreference.com". En.cppreference.com. 4 February 2014. Retrieved 6 March 2014.
  87. ^ "strtof, strtod, strtold - cppreference.com". En.cppreference.com. 4 February 2014. Retrieved 6 March 2014.
  88. ^ "wcstof, wcstod, wcstold - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  89. ^ "wcstof, wcstod, wcstold - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  90. ^ "wcstof, wcstod, wcstold - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  91. ^ "strtol, strtoll - cppreference.com". En.cppreference.com. 4 February 2014. Retrieved 6 March 2014.
  92. ^ "wcstol, wcstoll - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  93. ^ "strtoul, strtoull - cppreference.com". En.cppreference.com. 4 February 2014. Retrieved 6 March 2014.
  94. ^ "wcstoul, wcstoull - cppreference.com". En.cppreference.com. Retrieved 6 March 2014.
  95. ^ "WG14-N3020 : Qualifier-preserving standard library functions, v4" (PDF). open-std.org. 13 June 2022.
  96. ^ C99 Rationale, 7.20.1.1
  97. ^ "bzero". The Open Group. Retrieved 27 November 2017.
  98. ^ "bzero(3)". OpenBSD. Retrieved 27 November 2017.
  99. ^ "memccpy". Pubs.opengroup.org. Retrieved 6 March 2014.
  100. ^ "mempcpy(3) - Linux manual page". Kernel.org. Retrieved 6 March 2014.
  101. ^ "strcasecmp(3) - Linux manual page". Kernel.org. Retrieved 6 March 2014.
  102. ^ "strcat_s, wcscat_s, _mbscat_s". docs.microsoft.com. Retrieved 22 April 2022.
  103. ^ "strcpy_s, wcscpy_s, _mbscpy_s, _mbscpy_s_l". docs.microsoft.com. Retrieved 22 April 2022.
  104. ^ "strdup". Pubs.opengroup.org. Retrieved 6 March 2014.
  105. ^ "strerror(3) - Linux manual page". man7.org. Retrieved 3 November 2019.
  106. ^ "String | stricmp()". C Programming Expert.com. Retrieved 6 March 2014.
  107. ^ a b "strlcpy, strlcat — size-bounded string copying and concatenation". OpenBSD. Retrieved 26 May 2016.
  108. ^ a b c d Todd C. Miller; Theo de Raadt (1999). "strlcpy and strlcat – consistent, safe, string copy and concatenation". USENIX '99.
  109. ^ "strsignal". Pubs.opengroup.org. Retrieved 6 March 2014.
  110. ^ "strtok". Pubs.opengroup.org. Retrieved 6 March 2014.
  111. ^ Todd C. Miller. "strlcpy.c". BSD Cross Reference.
  112. ^ Todd C. Miller. "strlcat.c". BSD Cross Reference.
  113. ^ Miller, Damien (October 2005). "Secure Portability" (PDF). Retrieved 26 June 2016. This [strlcpy and strlcat] API has been adopted by most modern operating systems and many standalone software packages [...]. The notable exception is the GNU standard C library, glibc, whose maintainer steadfastly refuses to include these improved APIs, labelling them "horribly inefficient BSD crap", despite prior evidence that they are faster is most cases than the APIs they replace.
  114. ^ libc-alpha mailing list Archived 9 June 2007 at the Wayback Machine, selected messages from 8 August 2000 thread: 53, 60, 61
  115. ^ The ups and downs of strlcpy(); LWN.net
  116. ^ "Adding strlcpy() to glibc". lwn.net. Correct string handling means that you always know how long your strings are and therefore you can you memcpy (instead of strcpy).
  117. ^ strlcpy(3) – Linux Library Functions Manual "However, one may question the validity of such optimizations, as they defeat the whole purpose of strlcpy() and strlcat(). As a matter of fact, the first version of this manual page got it wrong."
  118. ^ "libbsd". Retrieved 21 November 2022.
  119. ^ "root/src/string/strlcpy.c". Retrieved 28 January 2017.
  120. ^ "root/src/string/strlcat.c". Retrieved 28 January 2017.
  121. ^ strlc{py|at} commit
  122. ^ Discussion of strlcpy and strlcat in glibc 2.38 on Hacker News
  123. ^ "strlcat". Pubs.opengroup.org. Retrieved 5 September 2024.
  124. ^ Lovell, Martyn. "Repel Attacks on Your Code with the Visual Studio 2005 Safe C and C++ Libraries". Retrieved 13 February 2015.
  125. ^ Safe C Library. "The Safe C Library provides bound checking memory and string functions per ISO/IEC TR24731". Sourceforge. Retrieved 6 March 2013.
  126. ^ "The C11 standard draft" (PDF). §K.3.1.4p2. Retrieved 13 February 2013.{{cite web}}: CS1 maint: location (link)
  127. ^ "The C11 standard draft" (PDF). §K.3.6.1.1p4. Retrieved 13 February 2013.{{cite web}}: CS1 maint: location (link)
  128. ^ "Parameter Validation". 21 October 2022.
  129. ^ Danny Kalev. "They're at it again". InformIT. Archived from the original on 15 January 2012. Retrieved 10 November 2011.
  130. ^ "Field Experience With Annex K — Bounds Checking Interfaces". Retrieved 5 November 2015.
  131. ^ "MSC06-C. Beware of compiler optimizations". SEI CERT C Coding Standard.
  132. ^ memset_s(3) – FreeBSD Library Functions Manual
[edit]
  • Fast memcpy in C, multiple C coding examples to target different types of CPU instruction architectures
胰岛素过高会导致什么 肝实质密度减低是什么意思 多囊卵巢有什么症状表现 荷里活什么意思 手麻是什么原因引起
什么的爱心 芭蕉和香蕉有什么区别 网罗是什么意思 1129什么星座 豆浆和豆奶有什么区别
内热外寒感冒用什么药 腊肉炒什么好吃 非萎缩性胃炎伴糜烂是什么意思 女人左手断掌什么命运 女生喝红牛有什么影响
什么时候闰十二月 地龙是什么动物 1940年中国发生了什么 次第花开是什么意思 eu是什么元素
吃饭流汗是什么原因hcv8jop3ns7r.cn 大腿肌肉跳动是什么原因gangsutong.com 减肥吃什么食物hcv9jop7ns9r.cn 紫癜吃什么药hcv8jop4ns9r.cn 什么是有机物什么是无机物hcv7jop5ns3r.cn
类风湿关节炎吃什么好hcv8jop5ns5r.cn 肠炎可以吃什么水果hcv9jop7ns9r.cn 治字五行属什么hcv9jop1ns9r.cn 食品科学与工程学什么tiangongnft.com 肉燕是什么huizhijixie.com
结膜炎吃什么消炎药hcv8jop3ns6r.cn 赤茯苓又叫什么hcv9jop7ns5r.cn 三月六号是什么星座hcv8jop7ns1r.cn 青春永驻是什么意思hcv8jop3ns7r.cn 什么时间是排卵期hcv8jop2ns4r.cn
夏天都有什么花hcv9jop5ns6r.cn 鹿晗的原名叫什么hcv9jop2ns9r.cn 突然肚子疼是什么原因sscsqa.com 吃东西想吐是什么原因cj623037.com 什么颜色加什么颜色等于紫色hcv7jop9ns6r.cn
百度