diff options
author | Jeremy Allison <jra@samba.org> | 2000-05-12 14:28:48 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-05-12 14:28:48 +0000 |
commit | fa659fea9b0b71bf62de9dfec61160196c828da1 (patch) | |
tree | c0f4b510ba60b3b0a6542a0b7390459940e87892 /source3/lib | |
parent | 0806cf75ff96dee6715610bd61e21cde08fa1c61 (diff) | |
download | samba-fa659fea9b0b71bf62de9dfec61160196c828da1.tar.gz samba-fa659fea9b0b71bf62de9dfec61160196c828da1.tar.bz2 samba-fa659fea9b0b71bf62de9dfec61160196c828da1.zip |
Added unicode_to_dos_char() function to address converting single UNICODE
characters to one or more DOS codepage characters.
Jeremy.
(This used to be commit eefbfb5e16fcf40f335edc840a49f837f6b64111)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_unistr.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 4a66adc0fd..c28ef44934 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -780,6 +780,28 @@ char *unicode_to_dos(char *dst, const smb_ucs2_t *src, size_t dst_len) } /******************************************************************* + Convert a single UNICODE character to DOS codepage. Returns the + number of bytes in the DOS codepage character. +********************************************************************/ + +size_t unicode_to_dos_char(char *dst, const smb_ucs2_t src) +{ + smb_ucs2_t val = ucs2_to_doscp[src]; + if(val < 256) { + *dst = (char)val; + return (size_t)1; + } + /* + * A 2 byte value is always written as + * high/low into the buffer stream. + */ + + dst[0] = (char)((val >> 8) & 0xff); + dst[1] = (char)(val & 0xff); + return (size_t)2; +} + +/******************************************************************* Convert a DOS string to UNICODE format. Note that the 'dst' is in native byte order, not little endian. Always zero terminates. This function may be replaced if the DOS codepage format is a |