Changeset da2bd08 in mainline for uspace/lib/libc/generic/string.c


Ignore:
Timestamp:
2009-11-29T14:53:18Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
272f88f0, 8b5001b
Parents:
025759c
Message:

Input history.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/string.c

    r025759c rda2bd08  
    583583}
    584584
     585/** Convert string to wide string.
     586 *
     587 * Convert string @a src to wide string. The output is written to the
     588 * buffer specified by @a dest and @a size, which must have non-zero
     589 * size. The output will always be null-terminated.
     590 *
     591 * @param dest  Destination buffer.
     592 * @param dlen  Length of destination buffer (number of wchars).
     593 * @param src   Source string.
     594 */
     595void str_to_wstr(wchar_t *dest, size_t dlen, const char *src)
     596{
     597        size_t offset;
     598        size_t di;
     599        wchar_t c;
     600
     601        assert(dlen > 0);
     602
     603        offset = 0;
     604        di = 0;
     605
     606        do {
     607                if (di >= dlen - 1)
     608                        break;
     609
     610                c = str_decode(src, &offset, STR_NO_LIMIT);
     611                dest[di++] = c;
     612        } while (c != '\0');
     613
     614        dest[dlen - 1] = '\0';
     615}
     616
    585617/** Find first occurence of character in string.
    586618 *
Note: See TracChangeset for help on using the changeset viewer.