Changeset 9553d7d in mainline


Ignore:
Timestamp:
2011-06-21T13:11:21Z (13 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2d0d637
Parents:
4372b49
Message:

Implement str_to_utf16 function.

Location:
uspace/srv/fs/fat
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_dentry.c

    r4372b49 r9553d7d  
    361361}
    362362
     363/** Convert string to utf16 string.
     364 *
     365 * Convert string @a src to wide string. The output is written to the
     366 * buffer specified by @a dest and @a dlen. @a dlen must be non-zero
     367 * and the wide string written will always be null-terminated.
     368 *
     369 * @param dest  Destination buffer.
     370 * @param dlen  Length of destination buffer (number of wchars).
     371 * @param src   Source string.
     372 */
     373int str_to_utf16(uint16_t *dest, size_t dlen, const char *src)
     374{
     375        size_t offset;
     376        size_t di;
     377        uint16_t c;
     378
     379        assert(dlen > 0);
     380
     381        offset = 0;
     382        di = 0;
     383
     384        do {
     385                if (di >= dlen - 1)
     386                        return EOVERFLOW;
     387
     388                c = str_decode(src, &offset, STR_NO_LIMIT);
     389                dest[di++] = c;
     390        } while (c != '\0');
     391
     392        dest[dlen - 1] = '\0';
     393        return EOK;
     394}
     395
    363396
    364397/**
  • uspace/srv/fs/fat/fat_dentry.h

    r4372b49 r9553d7d  
    141141extern size_t fat_lfn_copy_entry(const fat_dentry_t *, uint16_t *, size_t *);
    142142extern int utf16_to_str(char *, size_t, const uint16_t *);
     143extern int str_to_utf16(uint16_t *, size_t, const char *);
    143144
    144145
Note: See TracChangeset for help on using the changeset viewer.