char *charset_path=CHARSETPATH;
char *source_csname=SOURCE_CHARSET, *dest_csname=TARGET_CHARSET;
-short int * source_charset;
+uint16_t * source_charset;
int unknown_as_hex=0;
char bad_char[]=UNKNOWN_CHAR;
CHARSET target_charset;
/* Converts char in input charset into unicode representation */
/* Should be converted to macro */
/************************************************************************/
-int to_unicode (short int *charset, int c) {
+int to_unicode (uint16_t *charset, int c) {
return charset[c];
}
/************************************************************************/
/* Reads charset file (as got from ftp.unicode.org) and returns array of*/
/* 256 short ints (malloced) mapping from charset t unicode */
/************************************************************************/
-short int * read_charset(const char *filename) {
+uint16_t * read_charset(const char *filename) {
char *path;
FILE *f;
- short int *new;
+ uint16_t *new;
int c;
long int uc;
path= find_file(stradd(filename,CHARSET_EXT),charset_path);
if (c<0||c>255||uc<0||(uc>0xFEFE&& uc!=0xFFFE)) {
fprintf(stderr,"Invalid charset file %s\n",path);
fclose(f);
+ free(new);
return NULL;
}
new[c]=uc;
return 0xfeff; /*skip corrupted sequebces*/
if (c <0xE0) {
if (catdoc_read(buf+1, 1, 1, f)<=0) return EOF;
- return ((c & 0x1F)<<6 | ((char)buf[1] & 0x3F));
+ return (((c & 0x1F)<<6) | ((char)buf[1] & 0x3F));
}
if (c <0xF0) {
if (catdoc_read(buf+1, 1, 2, f)<=2) return (int)EOF;
}
struct cp_map {
- int codepage;
+ uint16_t codepage;
char *charset_name;
};