| 1 |
/* |
| 2 |
* $LynxId: UCMap.h,v 1.34 2025/09/17 23:12:02 tom Exp $ |
| 3 |
*/ |
| 4 |
#ifndef UCMAP_H |
| 5 |
#define UCMAP_H |
| 6 |
|
| 7 |
#ifndef HTUTILS_H |
| 8 |
#include <HTUtils.h> |
| 9 |
#endif |
| 10 |
|
| 11 |
#ifdef __cplusplus |
| 12 |
extern "C" { |
| 13 |
#endif |
| 14 |
|
| 15 |
#define UCS_LRM 0x200E /* left-to-right mark */ |
| 16 |
#define UCS_RLM 0x200F /* right-to-left mark */ |
| 17 |
#define UCS_ZWNBSP 0xFEFF /* BOM -- or zero width no-break space */ |
| 18 |
|
| 19 |
#define UCS_REPL 0xFFFD |
| 20 |
#define UCS_HIDE 0xFFFF |
| 21 |
|
| 22 |
#define is_ucs_spacing(n) \ |
| 23 |
(((n) >= 0x2002 && (n) <= 0x200A)) |
| 24 |
|
| 25 |
#define is_ucs_zero_width(n) \ |
| 26 |
((n) == UCS_ZWNBSP || ((n) >= 0x200B && (n) <= 0x200F)) |
| 27 |
|
| 28 |
typedef enum { |
| 29 |
ucError = -1, |
| 30 |
ucZeroWidth = -2, |
| 31 |
ucInvalidHash = -3, |
| 32 |
ucNotFound = -4, |
| 33 |
ucNeedMore = -10, |
| 34 |
ucCannotConvert = -11, |
| 35 |
ucCannotOutput = -12, |
| 36 |
ucBufferTooSmall = -13, |
| 37 |
ucUnknown = -14 |
| 38 |
} UCStatus; |
| 39 |
|
| 40 |
typedef long UCode_t; |
| 41 |
|
| 42 |
extern BOOL UCScanCode(UCode_t *, const char *, BOOL); |
| 43 |
|
| 44 |
extern int UCTransUniChar(UCode_t unicode, |
| 45 |
int charset_out); |
| 46 |
extern int UCTransUniCharStr(char *outbuf, |
| 47 |
int buflen, |
| 48 |
UCode_t unicode, |
| 49 |
int charset_out, |
| 50 |
int chk_single_flag); |
| 51 |
extern int UCTransChar(int ch_in, |
| 52 |
int charset_in, |
| 53 |
int charset_out); |
| 54 |
extern int UCReverseTransChar(int ch_out, |
| 55 |
int charset_in, |
| 56 |
int charset_out); |
| 57 |
extern int UCTransCharStr(char *outbuf, |
| 58 |
int buflen, |
| 59 |
int ch_in, |
| 60 |
int charset_in, |
| 61 |
int charset_out, |
| 62 |
int chk_single_flag); |
| 63 |
#ifdef EXP_CHINESEUTF8_SUPPORT |
| 64 |
extern UCode_t UCTransJPToUni(char *inbuf, |
| 65 |
int buflen, |
| 66 |
int charset_in); |
| 67 |
#endif |
| 68 |
extern UCode_t UCTransToUni(int ch_in, |
| 69 |
int charset_in); |
| 70 |
extern int UCGetRawUniMode_byLYhndl(int i); |
| 71 |
extern int UCGetLYhndl_byMIME(const char *p); /* returns -1 if name not recognized */ |
| 72 |
extern int safeUCGetLYhndl_byMIME(const char *p); /* returns LATIN1 if name not recognized */ |
| 73 |
|
| 74 |
#ifdef USE_LOCALE_CHARSET |
| 75 |
extern void LYFindLocaleCharset(void); |
| 76 |
#endif |
| 77 |
|
| 78 |
extern int UCLYhndl_for_unspec; |
| 79 |
extern int UCLYhndl_for_unrec; |
| 80 |
extern int UCLYhndl_HTFile_for_unspec; |
| 81 |
extern int UCLYhndl_HTFile_for_unrec; |
| 82 |
|
| 83 |
/* easy to type: */ |
| 84 |
extern int LATIN1; /* UCGetLYhndl_byMIME("iso-8859-1") */ |
| 85 |
extern int US_ASCII; /* UCGetLYhndl_byMIME("us-ascii") */ |
| 86 |
extern int UTF8_handle; /* UCGetLYhndl_byMIME("utf-8") */ |
| 87 |
|
| 88 |
#undef TRANSPARENT /* defined on Solaris in <sys/stream.h> */ |
| 89 |
extern int TRANSPARENT; /* UCGetLYhndl_byMIME("x-transparent") */ |
| 90 |
|
| 91 |
/* |
| 92 |
In general, Lynx translates letters from document charset to display charset. |
| 93 |
If document charset is not specified or not recognized by Lynx, we fall back |
| 94 |
to different assumptions below, read also lynx.cfg for info. |
| 95 |
|
| 96 |
UCLYhndl_for_unspec - assume this as charset for documents that don't |
| 97 |
specify a charset parameter in HTTP headers or via META |
| 98 |
this corresponds to "assume_charset" |
| 99 |
|
| 100 |
UCLYhndl_HTFile_for_unspec - assume this as charset of local file |
| 101 |
this corresponds to "assume_local_charset" |
| 102 |
|
| 103 |
UCLYhndl_for_unrec - in case a charset parameter is not recognized; |
| 104 |
this corresponds to "assume_unrec_charset" |
| 105 |
|
| 106 |
UCLYhndl_HTFile_for_unrec - the same but only for local files, |
| 107 |
currently not used. |
| 108 |
|
| 109 |
current_char_set - this corresponds to "display charset", |
| 110 |
declared in LYCharSets.c and really important. |
| 111 |
|
| 112 |
All external charset information is available in so called MIME format. |
| 113 |
For internal needs Lynx uses charset handlers as integers |
| 114 |
from UCGetLYhndl_byMIME(). However, there is no way to recover |
| 115 |
from user's error in configuration file lynx.cfg or command line switches, |
| 116 |
those unrecognized MIME names are assumed as LATIN1 (via safeUCGetLYhndl...). |
| 117 |
*/ |
| 118 |
|
| 119 |
#define UCTRANS_NOTFOUND (-4) |
| 120 |
|
| 121 |
#ifdef __cplusplus |
| 122 |
} |
| 123 |
#endif |
| 124 |
#endif /* UCMAP_H */ |