Changeset b06414f in mainline for uspace/lib/c/generic/str.c
- Timestamp:
- 2017-05-19T14:04:36Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e540bc87
- Parents:
- 2628642
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
r2628642 rb06414f 951 951 } 952 952 953 int str_to_utf16(uint16_t *dest, size_t size, const char *src) 953 /** Convert string to UTF16 string. 954 * 955 * Convert string @a src to utf16 string. The output is written to the buffer 956 * specified by @a dest and @a dlen. @a dlen must be non-zero and the string 957 * written will always be well-formed. Surrogate pairs also supported. 958 * 959 * @param dest Destination buffer. 960 * @param dlen Number of utf16 characters that fit in the destination buffer. 961 * @param src Source string. 962 * 963 * @return EOK, if success, negative otherwise. 964 */ 965 int str_to_utf16(uint16_t *dest, size_t dlen, const char *src) 954 966 { 955 967 int rc = EOK; … … 958 970 wchar_t c; 959 971 960 assert( size> 0);972 assert(dlen > 0); 961 973 962 974 while ((c = str_decode(src, &offset, STR_NO_LIMIT)) != 0) { 963 975 if (c > 0x10000) { 964 if (idx + 2 >= size- 1) {976 if (idx + 2 >= dlen - 1) { 965 977 rc = EOVERFLOW; 966 978 break; … … 975 987 976 988 idx++; 977 if (idx >= size- 1) {989 if (idx >= dlen - 1) { 978 990 rc = EOVERFLOW; 979 991 break;
Note:
See TracChangeset
for help on using the changeset viewer.