[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev Tweaking HTML.c to insert characters (was: UTF-8 display qu
From: |
Klaus Weide |
Subject: |
Re: lynx-dev Tweaking HTML.c to insert characters (was: UTF-8 display questions) |
Date: |
Thu, 8 Jun 2000 11:29:50 -0500 (CDT) |
I have to correct my previous message.
On Thu, 8 Jun 2000, Klaus Weide wrote:
> {
> char replace_buf[8]; /* or bigger */
> if (
> UCTransUniCharStr(replace_buf, sizeof(replace_buf),
> 0x2018, /* whatever Unicode character */
> current_char_set, /* display character set */
> 1) >= 0
> ) {
> HTML_put_string(me, replace_buf);
> } else {
> /* UCTransUniCharStr shouldn't fail, but just in case, some
> fallback: */
> HTML_put_character(me, '`');
> }
> }
>
> UCTransUniCharStr will just UTF-8-encode the Unicode value if
> current_char_set says UTF-8,
Err, wouldn't it be nice, but it doesn't.
I offer two alternatives instead; the first has the UTF-8 hardwired,
in the interest of avoiding unnecessary calls.
{
UCode_t code = 0x2018; /* hardwired Unicode character */
char replace_buf[8] = "\342\200\230"; /* hardwired UTF-8 for it */ */
int outlen = 3; /* */
if (LYCharSet_UC[current_char_set].enc != UCT_ENC_UTF8) {
outlen = UCTransUniCharStr(replace_buf, sizeof(replace_buf),
code, /* whatever Unicode character */
current_char_set, /* display character set */
1);
}
if (outlen >= 0) {
HTML_put_string(me, replace_buf);
} else {
/* UCTransUniCharStr shouldn't fail, but just in case, some
fallback: */
HTML_put_character(me, '`');
}
}
{
UCode_t code = 0x2018; /* hardwired Unicode character */
char replace_buf[8];
BOOLEAN ok;
if (LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8) {
ok = UCConvertUniToUtf8(code, replace_buf);
} else {
ok = (UCTransUniCharStr(replace_buf, sizeof(replace_buf),
code, /* whatever Unicode character */
current_char_set, /* display character set */
1) >= 0);
}
if (ok) {
HTML_put_string(me, replace_buf);
} else {
/* UCConvert / UCTransUniCharStr shouldn't fail, but just in case,
some fallback: */
HTML_put_character(me, '`');
}
}
> This is completely untested; if you use it, let us know how it goes.
Still true.
Klaus
; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden
- Re: lynx-dev UTF-8 display questions (was: Superscripts), (continued)
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Thomas E. Dickey, 2000/06/08
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Klaus Weide, 2000/06/08
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Thomas E. Dickey, 2000/06/08
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Sergei Pokrovsky, 2000/06/09
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Thomas E. Dickey, 2000/06/09
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Klaus Weide, 2000/06/09
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Sergei Pokrovsky, 2000/06/09
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Thomas E. Dickey, 2000/06/09
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Thomas Dickey, 2000/06/09
- lynx-dev Tweaking HTML.c to insert characters (was: UTF-8 display questions), Klaus Weide, 2000/06/08
- Re: lynx-dev Tweaking HTML.c to insert characters (was: UTF-8 display questions),
Klaus Weide <=
- Re: lynx-dev Tweaking HTML.c to insert characters (was: UTF-8 display questions), Sergei Pokrovsky, 2000/06/09
- Re: lynx-dev Tweaking HTML.c to insert characters (was: UTF-8 display questions), Klaus Weide, 2000/06/09
- Re: lynx-dev Tweaking HTML.c to insert characters (was: UTF-8 display questions), Sergei Pokrovsky, 2000/06/11
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Sergei Pokrovsky, 2000/06/11
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Klaus Weide, 2000/06/12
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Sergei Pokrovsky, 2000/06/12
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Klaus Weide, 2000/06/12
- Re: lynx-dev UTF-8 display questions (was: Superscripts), Sergei Pokrovsky, 2000/06/13
- lynx-dev Fun with character attributes in xterm (was: UTF-8 display questions), Klaus Weide, 2000/06/13
- Re: lynx-dev Fun with character attributes in xterm (was: UTF-8 display questions), Thomas E. Dickey, 2000/06/13