Commit 4e5abb29 authored by John Beranek's avatar John Beranek
Browse files

More syncronisation with Unicode lib in branched tree

Detail:
  Added some changes from Unicode lib in branched tree.  All basically
   type changes.  This appears to be because other compilers are
   more picky about types than armcc.

Admin:
  Will add 0.46 VersionNum file into branched tree, and all will be
   syncronised fully.


Version 0.46. Tagged as 'Unicode-0_46'
parent 354b54fc
/* (0.45)
/* (0.46)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 0.45
#define Module_MajorVersion_CMHG 0.46
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 05 Oct 2000
#define Module_Date_CMHG 13 Oct 2000
#define Module_MajorVersion "0.45"
#define Module_Version 45
#define Module_MajorVersion "0.46"
#define Module_Version 46
#define Module_MinorVersion ""
#define Module_Date "05 Oct 2000"
#define Module_Date "13 Oct 2000"
#define Module_ApplicationDate2 "05-Oct-00"
#define Module_ApplicationDate4 "05-Oct-2000"
#define Module_ApplicationDate2 "13-Oct-00"
#define Module_ApplicationDate4 "13-Oct-2000"
#define Module_FullVersion "0.45"
#define Module_HelpVersion "0.45 (05 Oct 2000)"
#define Module_FullVersion "0.46"
#define Module_HelpVersion "0.46 (13 Oct 2000)"
......@@ -35,7 +35,7 @@
typedef struct
{
UCS2 u;
char c;
unsigned char c;
} key_pair;
static key_pair fuzzy_specials[] =
......@@ -77,9 +77,9 @@ static key_pair fuzzy_specials[] =
{ 0, 0 }
};
static int acorn_write(EncodingPriv *e, UCS4 u, char **s, int *bufsize)
static int acorn_write(EncodingPriv *e, UCS4 u, unsigned char **s, int *bufsize)
{
int c;
unsigned char c;
if (u == NULL_UCS4)
return 0;
......
......@@ -90,8 +90,9 @@ static int get_return_val(int whatcode, int state)
return autojp_DECIDED;
}
int autojp_consume(int *pencoding, int *pstate, int c)
int autojp_consume(int *pencoding, int *pstate, char cc)
{
unsigned char c = (unsigned char)cc;
int whatcode = *pencoding;
int state = *pstate;
......@@ -225,7 +226,7 @@ int autojp_consume_string(int *pencoding, int *pstate, const char *buffer, int *
for (i = 1; i <= n; i++)
{
char c = *buffer++;
unsigned char c = (unsigned char)*buffer++;
determined = autojp_consume(pencoding, pstate, c);
......
......@@ -34,7 +34,7 @@
typedef struct BigFive_Encoding
{
EncodingPriv e;
char prev;
unsigned char prev;
encoding_table table;
} BigFive_Encoding;
......@@ -45,7 +45,7 @@ typedef struct BigFive_Encoding
* CN-Big5
*/
static UCS4 bigfive_to_ucs(const UCS2 *table, int c1, int c2)
static UCS4 bigfive_to_ucs(const UCS2 *table, unsigned char c1, unsigned char c2)
{
/*
* Big Five encodes kanji using byte pairs:
......@@ -94,7 +94,7 @@ static int bigfive_reset(Encoding *e, int for_encoding)
static unsigned int bigfive_read(Encoding *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -104,7 +104,7 @@ static unsigned int bigfive_read(Encoding *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u;
if (s5->prev)
......@@ -135,7 +135,7 @@ static unsigned int bigfive_read(Encoding *e,
return n - count;
}
static int bigfive_write(EncodingPriv *e, UCS4 u, char **bf, int *bufsize)
static int bigfive_write(EncodingPriv *e, UCS4 u, unsigned char **bf, int *bufsize)
{
BigFive_Encoding *s5 = (BigFive_Encoding *) e;
......
......@@ -149,7 +149,7 @@ int combine_characters(UCS4 previous, UCS4 current, UCS4 *replacement)
if (base_table == NULL)
{
r = combine_NOT_COMBINING;
replace = current;
replace = (UCS2)current;
}
else if (previous > 0xFFFF)
{
......
......@@ -52,7 +52,7 @@ int eightbit_reset(Encoding *e, int for_encoding)
unsigned int eightbit_read(EncodingPriv *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -62,7 +62,7 @@ unsigned int eightbit_read(EncodingPriv *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u = c < 0x80 ? c : table[c - 0x80];
if (u == NULL_UCS2)
......@@ -76,7 +76,7 @@ unsigned int eightbit_read(EncodingPriv *e,
return n - count;
}
int eightbit_write(EncodingPriv *e, UCS4 u, char **s, int *bufsize)
int eightbit_write(EncodingPriv *e, UCS4 u, unsigned char **s, int *bufsize)
{
EightBit_Encoding *ee = (EightBit_Encoding *) e;
int i, c;
......
......@@ -48,7 +48,7 @@
static unsigned int ascii_read(Encoding *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -56,7 +56,7 @@ static unsigned int ascii_read(Encoding *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u = c < 0x80 ? c : 0xFFFD;
if (ucs_out)
......@@ -69,7 +69,7 @@ static unsigned int ascii_read(Encoding *e,
NOT_USED(e);
}
static int ascii_write(EncodingPriv *e, UCS4 u, char **s, int *bufsize)
static int ascii_write(EncodingPriv *e, UCS4 u, unsigned char **s, int *bufsize)
{
int c;
......
......@@ -254,7 +254,7 @@ static int scsu_reset(Encoding *e, int for_encoding)
static unsigned int scsu_read(Encoding *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -524,7 +524,7 @@ static int is_single_byte(SCSU_Encoding *se, UCS4 u, int window)
return is_valid_ascii(u) || u - se->dynamic_window[window] < 0x80u;
}
static int output(int c, char **out, int *outsize)
static int output(int c, unsigned char **out, int *outsize)
{
if ((*outsize)-- > 0)
{
......@@ -542,7 +542,7 @@ static int output(int c, char **out, int *outsize)
* Uses the same members of SCSU_Encoding as reading, but we only use
* states SingleByte and Unicode.
*/
static int scsu_write(EncodingPriv *e, UCS4 u, char **buf, int *bufsize)
static int scsu_write(EncodingPriv *e, UCS4 u, unsigned char **buf, int *bufsize)
{
SCSU_Encoding *se = (SCSU_Encoding *) e;
SCSU_State state = se->state;
......@@ -796,7 +796,7 @@ static int scsu_write(EncodingPriv *e, UCS4 u, char **buf, int *bufsize)
* = 4 bytes, the same as staying in Unicode).
*/
if (!is_valid_ascii(next) /* Not valid ASCII / ctrl */
&& next - window_offset(w) >= 0x80u) /* Not in new window */
&& next - window_offset((unsigned char)w) >= 0x80u) /* Not in new window */
{
goto output_unicode;
}
......@@ -832,7 +832,7 @@ static int scsu_write(EncodingPriv *e, UCS4 u, char **buf, int *bufsize)
OUTPUT(w);
base = window_offset(w);
base = window_offset((unsigned char)w);
#ifdef DEBUG_SCSU_COMPRESSION
fprintf(stderr, "%02X %02X [Window %d = %04X]\n",
......@@ -853,7 +853,7 @@ static int scsu_write(EncodingPriv *e, UCS4 u, char **buf, int *bufsize)
se->learning_from = se->window_no;
se->learning_to = window_no;
}
se->lock_to[window_no] = default_lock_to(w);
se->lock_to[window_no] = default_lock_to((unsigned char)w);
se->dynamic_window[window_no] = base;
se->window_last_used[window_no] = se->count++;
}
......
......@@ -72,7 +72,7 @@ static int system_reset(Encoding *e, int for_encoding)
static unsigned int system_read(EncodingPriv *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -81,7 +81,7 @@ static unsigned int system_read(EncodingPriv *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u;
if (se->lookup)
......@@ -100,7 +100,7 @@ static unsigned int system_read(EncodingPriv *e,
return n - count;
}
static int system_write(EncodingPriv *e, UCS4 u, char **s, int *bufsize)
static int system_write(EncodingPriv *e, UCS4 u, unsigned char **s, int *bufsize)
{
System_Encoding *se = (System_Encoding *) e;
int i, c = -1;
......
......@@ -36,11 +36,11 @@ typedef struct UCS4_Encoding
EncodingPriv e;
union
{
char byte[4];
unsigned char byte[4];
UCS4 word;
} code;
char sync;
char first;
unsigned char sync;
unsigned char first;
} UCS4_Encoding;
/*
......@@ -64,7 +64,7 @@ static int ucs4_reset(Encoding *e, int for_encoding)
static unsigned int ucs4_read(Encoding *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -73,7 +73,7 @@ static unsigned int ucs4_read(Encoding *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u;
if (ue->e.flags & encoding_FLAG_LITTLE_ENDIAN)
......@@ -115,7 +115,7 @@ static unsigned int ucs4_read(Encoding *e,
return n - count;
}
static char *write_be(char *p, UCS4 u)
static unsigned char *write_be(unsigned char *p, UCS4 u)
{
*p++ = (u >> 24) & 0xff;
*p++ = (u >> 16) & 0xff;
......@@ -125,7 +125,7 @@ static char *write_be(char *p, UCS4 u)
return p;
}
static char *write_le(char *p, UCS4 u)
static unsigned char *write_le(unsigned char *p, UCS4 u)
{
*p++ = u & 0xff;
*p++ = (u >> 8) & 0xff;
......@@ -135,10 +135,10 @@ static char *write_le(char *p, UCS4 u)
return p;
}
static int ucs4_write(EncodingPriv *e, UCS4 u, char **pucs4, int *bufsize)
static int ucs4_write(EncodingPriv *e, UCS4 u, unsigned char **pucs4, int *bufsize)
{
UCS4_Encoding *ue = (UCS4_Encoding *) e;
char *ucs4;
unsigned char *ucs4;
int size = ue->first && !(ue->e.flags & encoding_FLAG_NO_HEADER) ? 8 : 4;
if (u == NULL_UCS4)
......
......@@ -35,9 +35,9 @@ typedef struct UTF16_Encoding
{
EncodingPriv e;
UCS2 prev_surrogate;
char prev;
char sync;
char first;
unsigned char prev;
unsigned char sync;
unsigned char first;
} UTF16_Encoding;
/*
......@@ -63,7 +63,7 @@ static int utf16_reset(Encoding *e, int for_encoding)
static unsigned int utf16_read(Encoding *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -72,7 +72,7 @@ static unsigned int utf16_read(Encoding *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u;
if (ue->sync)
......@@ -128,7 +128,7 @@ static unsigned int utf16_read(Encoding *e,
return n - count;
}
static char *write_be(char *p, UCS2 u)
static unsigned char *write_be(unsigned char *p, UCS2 u)
{
*p++ = u >> 8;
*p++ = u & 0xff;
......@@ -136,7 +136,7 @@ static char *write_be(char *p, UCS2 u)
return p;
}
static char *write_le(char *p, UCS2 u)
static unsigned char *write_le(unsigned char *p, UCS2 u)
{
*p++ = u & 0xff;
*p++ = u >> 8;
......@@ -144,12 +144,13 @@ static char *write_le(char *p, UCS2 u)
return p;
}
static int utf16_write(EncodingPriv *e, UCS4 u, char **putf16, int *bufsize)
static int utf16_write(EncodingPriv *e, UCS4 u, unsigned char **putf16, int *bufsize)
{
UTF16_Encoding *ue = (UTF16_Encoding *) e;
unsigned int flags = ue->e.flags;
char *utf16;
int c = 0, cc = 0, bom = 0;
unsigned char *utf16;
UCS2 c = 0, cc = 0;
int bom = 0;
if (u == NULL_UCS4)
return 0;
......
......@@ -44,8 +44,8 @@ typedef struct UTF7_Encoding
UCS4 buffer;
UTF7_State state;
int bits;
char just_shifted;
char written_something;
unsigned char just_shifted;
unsigned char written_something;
} UTF7_Encoding;
static const char *B="ABCDEFGHIJKLMNOP"
......@@ -99,7 +99,7 @@ static int utf7_reset(Encoding *e, int for_encoding)
static unsigned int utf7_read(Encoding *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -108,7 +108,7 @@ static unsigned int utf7_read(Encoding *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u;
if (ue->state == Direct)
......@@ -184,7 +184,7 @@ static unsigned int utf7_read(Encoding *e,
return n - count;
}
static int output(int c, char **out, int *outsize)
static int output(unsigned char c, unsigned char **out, int *outsize)
{
if ((*outsize)-- > 0)
{
......@@ -195,7 +195,7 @@ static int output(int c, char **out, int *outsize)
return 0;
}
static int utf7_write(EncodingPriv *e, UCS4 u, char **utf7, int *bufsize)
static int utf7_write(EncodingPriv *e, UCS4 u, unsigned char **utf7, int *bufsize)
{
UTF7_Encoding *ue = (UTF7_Encoding *) e;
UTF7_State state = ue->state;
......@@ -273,7 +273,7 @@ static int utf7_write(EncodingPriv *e, UCS4 u, char **utf7, int *bufsize)
}
if (!needshift && u != NULL_UCS4)
ok = OUTPUT(u);
ok = OUTPUT((unsigned char)u);
if (surrogate)
{
......
......@@ -53,7 +53,7 @@ static int utf8_reset(Encoding *e, int for_encoding)
static unsigned int utf8_read(Encoding *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -62,7 +62,7 @@ static unsigned int utf8_read(Encoding *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u;
retry:
......@@ -119,7 +119,7 @@ static unsigned int utf8_read(Encoding *e,
return n - count;
}
static int utf8_write(EncodingPriv *e, UCS4 u, char **utf8, int *bufsize)
static int utf8_write(EncodingPriv *e, UCS4 u, unsigned char **utf8, int *bufsize)
{
UTF8_Encoding *ue = (UTF8_Encoding *) e;
int len;
......@@ -135,8 +135,8 @@ static int utf8_write(EncodingPriv *e, UCS4 u, char **utf8, int *bufsize)
if ((*bufsize -= bom + len) < 0 || !utf8)
return 0;
if (bom) *utf8 = UCS4_to_UTF8(*utf8, 0xFEFF);
*utf8 = UCS4_to_UTF8(*utf8, u);
if (bom) *utf8 = (unsigned char *)UCS4_to_UTF8((char *)*utf8, 0xFEFF);
*utf8 = (unsigned char *)UCS4_to_UTF8((char *)*utf8, u);
return 1;
}
......
......@@ -252,7 +252,7 @@ unsigned encoding_read(Encoding *e, encoding_read_callback_fn ucs_out,
{
if (e && e->for_encoding == encoding_READ)
{
return e->read(e, ucs_out, s, n, handle);
return e->read(e, ucs_out, (const unsigned char *)s, n, handle);
}
return 0;
}
......@@ -261,7 +261,7 @@ int encoding_write(Encoding *e, UCS4 c, char **buf, int *bufsize)
{
if (e && e->for_encoding != encoding_READ)
{
return e->write(e, c, buf, bufsize);
return e->write(e, c, (unsigned char **)buf, bufsize);
}
return 0;
}
......@@ -445,11 +445,11 @@ static int encoding__number_from_name(const char *name)
const char *p = name;
char *temp, *tp;
struct EncList *e;
char c;
unsigned char c;
do
{
c = *p++;
c = (unsigned char)*p++;
} while (mime_token_char(c));
......
......@@ -862,7 +862,7 @@ static int iso2022_scan_sets(ISO2022_Encoding *enc, UCS4 u, int *index, int *tab
{
simple_set *setptr = (simple_set *) enc->Set[set];
/* fprintf(stderr, "scan_table: set %d table %p n %d\n", set, setptr->table, n_entries); */
/* UNIDBG(("scan_table: set %d table %p\n", set, setptr->table)); */
if ((i = encoding_lookup_in_table(u, setptr->table)) != -1)
{
......@@ -898,7 +898,8 @@ static int iso2022_write_euc(EncodingPriv *e, UCS4 u, char **euc, int *bufsize)
/* main chars */
else if (iso2022_scan_sets(enc, u, &index, &set, &n_entries))
{
/* fprintf(stderr, "iso2022_write_euc: u %04x index %d set %d size %d\n", u, index, set, n_entries); */
UNIDBG(("iso2022_write_euc: u %04x index %d set %d size %d\n",
u, index, set, n_entries));
switch (set)
{
case G0:
......
......@@ -35,7 +35,7 @@
typedef struct Johab_Encoding
{
EncodingPriv e;
char prev;
unsigned char prev;
encoding_table ksx1001;
} Johab_Encoding;
......@@ -69,14 +69,14 @@ static UCS4 hangul_to_ucs(unsigned int c1, unsigned int c2)
* Lookup tables from Johab 5-bit codes to UCS L,V,T index
* numbers (as described in Unicode "Combining Jamo behaviour")
*/
static const char initial_lookup[] = /* Add 0x1100 for UCS Jamo */
static const unsigned char initial_lookup[] = /* Add 0x1100 for UCS Jamo */
{
0, 0x80, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
0x0E, 0x0F, 0x10, 0x11, 0x12
};
static const char medial_lookup[] = /* Add 0x1161 for UCS Jamo */
static const unsigned char medial_lookup[] = /* Add 0x1161 for UCS Jamo */
{
0, 0, 0x80, 0x00, 0x01, 0x02, 0x03, 0x04,
0, 0, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
......@@ -84,7 +84,7 @@ static UCS4 hangul_to_ucs(unsigned int c1, unsigned int c2)
0, 0, 0x11, 0x12, 0x13, 0x14, 0xFF, 0xFF
};
static const char final_lookup[] = /* Add 0x11A7 for UCS Jamo */
static const unsigned char final_lookup[] = /* Add 0x11A7 for UCS Jamo */
{
0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
......@@ -111,7 +111,7 @@ static UCS4 hangul_to_ucs(unsigned int c1, unsigned int c2)
if (medial == 0x80) /* "fill" */
{
/* Hangul is --X */
static const char final_only[28] =
static const unsigned char final_only[28] =
{
0, 0, 0, 0x33, 0, 0x35, 0x36, 0,
0, 0, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
......@@ -138,7 +138,7 @@ static UCS4 hangul_to_ucs(unsigned int c1, unsigned int c2)
if (final == 0) /* "fill" */
{
/* Hangul is L-- */
static const char initial_only[19] =
static const unsigned char initial_only[19] =
{
0x31, 0x32, 0x34, 0x37, 0x38, 0x39, 0x41, 0x42,
0x43, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B,
......@@ -213,7 +213,7 @@ static int johab_reset(Encoding *e, int for_encoding)
static unsigned int johab_read(Encoding *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -223,7 +223,7 @@ static unsigned int johab_read(Encoding *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u;
if (je->prev)
......@@ -277,14 +277,14 @@ static int ucs_hangul_to_johab(UCS4 u)
/* Lookup tables from UCS Jamo index numbers to Johab bits */
static const char medial_lookup[] =
static const unsigned char medial_lookup[] =
{
0x03, 0x04, 0x05, 0x06, 0x07, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x12, 0x13, 0x14, 0x15, 0x16,
0x17, 0x1A, 0x1B, 0x1C, 0x1D
};
static const char final_lookup[] =
static const unsigned char final_lookup[] =
{
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
......@@ -323,7 +323,7 @@ static int ucs_jamo_to_johab(UCS4 u)
return jamo_lookup[u-0x3131];
}
static int johab_write(EncodingPriv *e, UCS4 u, char **johab, int *bufsize)
static int johab_write(EncodingPriv *e, UCS4 u, unsigned char **johab, int *bufsize)
{
Johab_Encoding *je = (Johab_Encoding *) e;
int c = '?';
......
......@@ -233,11 +233,11 @@ static int decode_line(char *cp, unicode_char_info *info)
static void write_nybble(unsigned char *ptr, int index, int value)
{
int c = ptr[index/2];
unsigned char c = ptr[index/2];
if (index & 1)
c = (c & 0x0f) | (value << 4);
c = (unsigned char)((c & 0x0f) | (value << 4));
else
c = (c & 0xf0) | (value);
c = (unsigned char)((c & 0xf0) | (value));
ptr[index/2] = c;
}
......@@ -265,6 +265,8 @@ int main(int argc, char *argv[])
}
info_last.range = range_UNKNOWN;
info_last.code = 0;
info_last.type = 0;
while (!feof(f_in) && !ferror(f_in))
{
char buf[512];
......
......@@ -36,7 +36,7 @@
typedef struct ShiftJIS_Encoding
{
EncodingPriv e;
char prev;
unsigned char prev;
encoding_table katakana, kanji, cp932ext;
} ShiftJIS_Encoding;
......@@ -139,7 +139,7 @@ static int shiftjis_reset(EncodingPriv *e, int for_encoding)
static unsigned int shiftjis_read(Encoding *e,
encoding_read_callback_fn ucs_out,
const char *s,
const unsigned char *s,
unsigned int n,
void *handle)
{
......@@ -151,7 +151,7 @@ static unsigned int shiftjis_read(Encoding *e,
for (count = n; count; count--)
{
char c = *s++;
unsigned char c = *s++;
UCS4 u;
if (sj->prev)
......@@ -256,7 +256,7 @@ static int lookup_table(UCS4 u, ShiftJIS_Encoding *sj, int *index, int *table_no
return 0;
}
static int shiftjis_write(EncodingPriv *e, UCS4 u, char **sjis, int *bufsize)
static int shiftjis_write(EncodingPriv *e, UCS4 u, unsigned char **sjis, int *bufsize)
{
ShiftJIS_Encoding *sj = (ShiftJIS_Encoding *) e;
int c = 0, cc = 0;
......
......@@ -38,15 +38,15 @@ UCS2 *UCS4_to_UTF16(UCS2 *out, UCS4 code)
{
if (code < 0x10000u)
{
*out++ = code;
*out++ = (UCS2)code;
return out;
}
if (code < 0x110000u)
{
code -= 0x10000u;
*out++ = 0xD800u | (code >> 10);
*out++ = 0xDC00u | (code & 0x3FFu);
*out++ = (UCS2)(0xD800u | (code >> 10));
*out++ = (UCS2)(0xDC00u | (code & 0x3FFu));
return out;
}
......
......@@ -38,13 +38,14 @@
*/
char *UCS4_to_UTF8(char *out, UCS4 code)
{
char *p;
unsigned char *p;
int len;
p = (unsigned char *)out;
if (code < 0x80u)
{
*out++ = code;
return out;
*p++ = (unsigned char)code;
return (char *)p;
}
/* Illegal codes -> replacement character */
......@@ -62,26 +63,27 @@ char *UCS4_to_UTF8(char *out, UCS4 code)
else
len = 6;
p = out + len - 1;
p = (unsigned char *)out + len - 1;
do
{
*p-- = 0x80u | (code & 0x3Fu);
*p-- = (unsigned char)(0x80u | (code & 0x3Fu));
code >>= 6;
}
while (p > out);
while (p > (unsigned char *)out);
*p = (0xFF00u >> len) | code;
*p = (unsigned char)((0xFF00u >> len) | code);
return out + len;
return (char *)out + len;
}
/*
* UTF8_to_UCS4 takes a pointer to a UTF-8 sequence and outputs
* the corresponding UCS4 code, returning the number of bytes consumed.
*/
int UTF8_to_UCS4(const char *c, UCS4 *r)
int UTF8_to_UCS4(const char *cc, UCS4 *r)
{
const unsigned char *c = (const unsigned char *)cc;
UCS4 c0 = c[0];
UCS4 ucs, cn;
......@@ -236,8 +238,9 @@ int UTF8_codelen(UCS4 code)
* UTF8_seqlen gives the length of a UTF-8 sequence, given its first
* byte.
*/
int UTF8_seqlen(char c)
int UTF8_seqlen(char cc)
{
unsigned char c = (unsigned char)cc;
if (c < 0xC0u) return 1;
if (c < 0xE0u) return 2;
if (c < 0xF0u) return 3;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment