From 529b3f6fffd9ed9742009162077ea5c98325d2a9 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 10 Sep 2007 09:53:07 +0000 Subject: *** empty log message *** --- src/util.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 104a16c..f59ccb9 100644 --- a/src/util.c +++ b/src/util.c @@ -53,8 +53,11 @@ hexdump (FILE * f, uint8_t * data, int s, int l) } void -utf16_to_ascii (uint16_t * u16, int u16_len, uint8_t * u8, int u8_len) +utf16_to_ascii (void * _u16, int u16_len, void * _u8, int u8_len) { + uint16_t *u16=(uint16_t *) _u16; + uint8_t *u8=(uint8_t *) _u8; + u16_len >>= 1; if (u8_len == 1) @@ -78,3 +81,37 @@ utf16_to_ascii (uint16_t * u16, int u16_len, uint8_t * u8, int u8_len) *u8 = 0; return; } + +void +ascii_to_utf16 (void * _u8, int u8_len, void * _u16, int u16_len) +{ + uint16_t *u16=(uint16_t *) _u16; + uint8_t *u8=(uint8_t *) _u8; + + u16_len >>= 1; + + if (u16_len == 1) + { + *u16 = 0; + return; + } + while (*u8 && u8_len) + { + *(u16++) = *(u8++); + u16_len--; + u8_len--; + + if (u16_len == 1) + { + *u16 = 0; + return; + } + } + + *u16 = 0; + return; +} + + + + -- cgit v1.2.3