Changeset b2906c0 in mainline for uspace/lib/c


Ignore:
Timestamp:
2017-07-11T18:44:04Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f3504c1
Parents:
9bf4488
Message:

One function to compute the number of code units in a UTF-16 null-terminated string.

Location:
uspace/lib/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/str.c

    r9bf4488 rb2906c0  
    995995        dest[idx] = '\0';
    996996        return rc;
     997}
     998
     999/** Get size of UTF-16 string.
     1000 *
     1001 * Get the number of words which are used by the UTF-16 string @a ustr
     1002 * (excluding the NULL-terminator).
     1003 *
     1004 * @param ustr UTF-16 string to consider.
     1005 *
     1006 * @return Number of words used by the UTF-16 string
     1007 *
     1008 */
     1009size_t utf16_wsize(const uint16_t *ustr)
     1010{
     1011        size_t wsize = 0;
     1012
     1013        while (*ustr++ != 0)
     1014                wsize++;
     1015
     1016        return wsize;
    9971017}
    9981018
  • uspace/lib/c/include/str.h

    r9bf4488 rb2906c0  
    9999extern int utf16_to_str(char *dest, size_t size, const uint16_t *src);
    100100extern int str_to_utf16(uint16_t *dest, size_t dlen, const char *src);
     101extern size_t utf16_wsize(const uint16_t *ustr);
    101102
    102103extern char *str_chr(const char *str, wchar_t ch);
Note: See TracChangeset for help on using the changeset viewer.