diff options
Diffstat (limited to 'winsup/cygwin/wchar.h')
-rw-r--r-- | winsup/cygwin/wchar.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/winsup/cygwin/wchar.h b/winsup/cygwin/wchar.h index ff1d4f1..0484b27 100644 --- a/winsup/cygwin/wchar.h +++ b/winsup/cygwin/wchar.h @@ -92,9 +92,21 @@ sys_mbstowcs (wchar_t * dst, size_t dlen, const char *src, size_t sys_mbstowcs_alloc (wchar_t **, int, const char *, size_t = (size_t) -1); static inline size_t +sys_mbstouni (PUNICODE_STRING dst, int type, const char *src, + size_t nms = (size_t) -1) +{ + /* sys_mbstowcs returns length *excluding* trailing \0 */ + size_t len = sys_mbstowcs (dst->Buffer, type, src, nms); + dst->Length = len * sizeof (WCHAR); + dst->MaximumLength = dst->Length + sizeof (WCHAR); + return dst->Length; +} + +static inline size_t sys_mbstouni_alloc (PUNICODE_STRING dst, int type, const char *src, size_t nms = (size_t) -1) { + /* sys_mbstowcs returns length *including* trailing \0 */ size_t len = sys_mbstowcs_alloc (&dst->Buffer, type, src, nms); dst->MaximumLength = len * sizeof (WCHAR); dst->Length = dst->MaximumLength - sizeof (WCHAR); |