1 /* $Id: macucs.c,v 1.4 2003/01/14 19:42:00 ben Exp $ */
14 * Mac Unicode-handling routines.
16 * FIXME: currently trivial stub versions assuming all codepages
19 * What we _should_ do is to use the Text Encoding Conversion Manager
20 * when it's available, and have our own routines for converting to
21 * standard Mac OS scripts when it's not. Support for ATSUI might be
26 * Determine whether a byte is the first byte of a double-byte
27 * character in a system character set. Only MI use is by clipme()
28 * when copying direct-to-font text to the clipboard.
30 int is_dbcs_leadbyte(int codepage
, char byte
)
32 return 0; /* we don't do DBCS */
36 * Convert from Unicode to a system character set. MI uses are:
37 * (1) by lpage_send(), whose only MI use is to convert the answerback
38 * string to Unicode, and
39 * (2) by clipme() when copying direct-to-font text to the clipboard.
41 int mb_to_wc(int codepage
, int flags
, char *mbstr
, int mblen
,
42 wchar_t *wcstr
, int wclen
)
45 while (mblen
> 0 && wclen
> 0) {
46 *wcstr
++ = (unsigned char) *mbstr
++;
47 mblen
--, wclen
--, ret
++;
49 return ret
; /* FIXME: check error codes! */
53 * Convert from a system character set to Unicode. Used by luni_send
54 * to convert Unicode into the line character set.
56 int wc_to_mb(int codepage
, int flags
, wchar_t *wcstr
, int wclen
,
57 char *mbstr
, int mblen
, char *defchr
, int *defused
,
58 struct unicode_data
*ucsdata
)
63 while (mblen
> 0 && wclen
> 0) {
64 if (*wcstr
>= 0x100) {
72 *mbstr
++ = (unsigned char) *wcstr
;
74 mblen
--, wclen
--, ret
++;
76 return ret
; /* FIXME: check error codes! */
79 void init_ucs(Session
*s
)
83 /* Find the line control characters. FIXME: this is not right. */
84 for (i
= 0; i
< 256; i
++)
85 if (i
< ' ' || (i
>= 0x7F && i
< 0xA0))
86 s
->ucsdata
.unitab_ctrl
[i
] = i
;
88 s
->ucsdata
.unitab_ctrl
[i
] = 0xFF;
90 for (i
= 0; i
< 256; i
++) {
91 s
->ucsdata
.unitab_line
[i
] = s
->ucsdata
.unitab_scoacs
[i
] = i
;
92 s
->ucsdata
.unitab_xterm
[i
] =
93 (i
>= 0x5F && i
< 0x7F) ?
((i
+1) & 0x1F) : i
;