diff options
author | Luo Jinghua <sunmoon1997@gmail.com> | 2010-01-07 20:11:06 +0800 |
---|---|---|
committer | Luo Jinghua <sunmoon1997@gmail.com> | 2010-01-07 20:11:06 +0800 |
commit | 77ed4252c6c8b2c99069cc4f6214821a3068a04d (patch) | |
tree | 531358379503e29758b4d57c126cc53086cc4e1d | |
parent | c55b817add08717e5ac64720148d3afb205f4518 (diff) |
uniconv: replace short with uc_uint16_t
-rw-r--r-- | unicode.c | 5 | ||||
-rw-r--r-- | unicode.h | 4 | ||||
-rw-r--r-- | utfconverter.c | 19 |
3 files changed, 14 insertions, 14 deletions
@@ -12,7 +12,7 @@ unicode_valide(uc_char_t unichar) } int -ucs4toutf16(uc_char_t unichar, short *utf16) +ucs4toutf16(uc_char_t unichar, uc_uint16_t *utf16) { unsigned len; @@ -39,13 +39,12 @@ ucs4toutf16(uc_char_t unichar, short *utf16) } int -ucs4fromutf16(const short *str, uc_char_t *ret, int inlen) +ucs4fromutf16(const uc_uint16_t *utf16, uc_char_t *ret, int inlen) { static const uc_char_t UNI_SUR_HIGH_START = 0xd800; static const uc_char_t UNI_SUR_HIGH_END = 0xdbff; static const uc_char_t UNI_SUR_LOW_START = 0xdc00; static const uc_char_t UNI_SUR_LOW_END = 0xdfff; - const unsigned short *utf16 = (const unsigned short *)str; uc_char_t ch; int len = 1; @@ -4,10 +4,10 @@ #include <uniconvint.h> int -ucs4toutf16(uc_char_t unichar, short *utf16); +ucs4toutf16(uc_char_t unichar, uc_uint16_t *utf16); int -ucs4fromutf16(const short *utf16, uc_char_t *ucs4, int len); +ucs4fromutf16(const uc_uint16_t *utf16, uc_char_t *ucs4, int len); int ucs4toutf8(uc_char_t unichar, char *utf8); diff --git a/utfconverter.c b/utfconverter.c index 039c39f..9818c27 100644 --- a/utfconverter.c +++ b/utfconverter.c @@ -73,13 +73,13 @@ utf16_encode(struct converter *conv, size_t outleft) { size_t i; - short **soutbuf = (short **)outbuf; + uc_uint16_t **soutbuf = (uc_uint16_t **)outbuf; for (i = 0; i < inleft; i++) { int seqlen = ucs4toutf16(**inbuf, NULL); if (seqlen < 0) return UNICONV_EILSEQ; - if (seqlen * sizeof(short) > outleft) + if (seqlen * sizeof(uc_uint16_t) > outleft) return UNICONV_E2BIG; ucs4toutf16(**inbuf, *soutbuf); @@ -93,16 +93,17 @@ utf16_encode(struct converter *conv, static int utf16_decode(struct converter *conv, - const char **inbuf, - size_t inleft, - uc_char_t **outbuf, - size_t outleft) + const char **inbuf, + size_t inleft, + uc_char_t **outbuf, + size_t outleft) { - const short **sinbuf = (const short**)inbuf; + const uc_uint16_t **sinbuf = (const uc_uint16_t**)inbuf; while (inleft) { uc_char_t unichar; - int seqlen = ucs4fromutf16(*sinbuf, &unichar, inleft / sizeof(short)); + int seqlen = ucs4fromutf16(*sinbuf, &unichar, + inleft / sizeof(uc_uint16_t)); if (seqlen == -2) return UNICONV_E2BIG; else if (seqlen < 0) @@ -115,7 +116,7 @@ utf16_decode(struct converter *conv, outleft -= 1; (*sinbuf) += seqlen; - inleft -= seqlen * sizeof(short); + inleft -= seqlen * sizeof(uc_uint16_t); } return UNICONV_SUCCESS; |