1
1
#if !defined(lint) && !defined(DOS)
2
static char rcsid[] = "$Id: utf8.c 902 2008-01-08 17:04:58Z hubert@u.washington.edu $";
2
static char rcsid[] = "$Id: utf8.c 1019 2008-04-02 22:09:20Z hubert@u.washington.edu $";
6
6
* ========================================================================
7
* Copyright 2006-2007 University of Washington
7
* Copyright 2006-2008 University of Washington
9
9
* Licensed under the Apache License, Version 2.0 (the "License");
10
10
* you may not use this file except in compliance with the License.
1924
1924
#if PREREQ_FOR_SYS_TRANSLATION
1927
dcm = nl_langinfo(CODESET);
1927
dcm = nl_langinfo_codeset_wrapper();
1928
1928
dcm = dcm ? dcm : "US-ASCII";
1930
1930
init_utf8_display(0, NULL);
2120
* This function is only defined in this special case and so calls
2121
* to it should be wrapped in the same macro conditionals.
2123
* Returns the default display charset for a UNIX terminal emulator,
2124
* it is what nl_langinfo(CODESET) should return but we need to
2125
* wrap nl_langinfo because we know of strange behaving implementations.
2127
#if !defined(_WINDOWS) && HAVE_LANGINFO_H && defined(CODESET)
2129
nl_langinfo_codeset_wrapper(void)
2133
ret = nl_langinfo(CODESET);
2136
* If the value returned from nl_langinfo() is not a real charset,
2137
* see if we can figure out what they meant. If we can't figure it
2138
* out return NULL and let the caller decide what to do.
2140
if(ret && *ret && !output_charset_is_supported(ret)){
2141
if(!strcmp("ANSI_X3.4-1968", ret)
2142
|| !strcmp("ASCII", ret)
2143
|| !strcmp("C", ret)
2144
|| !strcmp("POSIX", ret))
2146
else if(!strucmp(ret, "UTF8"))
2148
else if(!strucmp(ret, "EUCJP"))
2150
else if(!strucmp(ret, "EUCKP"))
2152
else if(!strucmp(ret, "SJIS"))
2154
else if(strstr(ret, "8859")){
2157
/* check for digits after 8859 */
2158
p = strstr(ret, "8859");
2164
static char buf[12];
2166
memset(buf, 0, sizeof(buf));
2167
strncpy(buf, "ISO-8859-", sizeof(buf));
2177
if(ret && !output_charset_is_supported(ret))
2120
2186
* Convert the "orig" string from UTF-8 to "charset". If no conversion is
2121
2187
* needed the return value will point to orig. If a conversion is done,
2122
2188
* the return string should be freed by the caller.
2229
2295
line_paint(int offset, /* current dot offset into vl */
2230
2296
struct display_line *displ,
2231
int passwd) /* flag to hide display of chars */
2297
int *passwd) /* flag to hide display of chars */
2233
2299
int i, w, w2, already_got_one = 0;
2234
2300
int vfirst, vlast, dfirst, dlast, vi, di;
2236
2302
unsigned (*width_a_to_b)(UCS *, int, int);
2305
* Set passwd to 10 in caller if you want to conceal the
2306
* password but not print asterisks for feedback.
2308
* Set passwd to 1 in caller to conceal by printing asterisks.
2310
if(passwd && *passwd >= 10){ /* don't show asterisks */
2314
*passwd = 11; /* only blat once */
2317
(*displ->movecursor)(displ->row, displ->col);
2318
while(i++ <= displ->dwid)
2319
(*displ->writechar)(' ');
2321
(*displ->movecursor)(displ->row, displ->col);
2325
if(passwd && *passwd)
2239
2326
width_a_to_b = single_width_chars_a_to_b;
2241
2328
width_a_to_b = ucs4_str_width_a_to_b;
2354
2441
* Copy the relevant part of the virtual line into the display line.
2356
2443
for(vi = vfirst, di = dfirst; vi <= vlast; vi++, di++)
2444
if(passwd && *passwd)
2358
2445
displ->dl[di] = '*'; /* to conceal password */
2360
2447
displ->dl[di] = displ->vl[vi];