On Wed, Feb 13, 2002 at 11:35:26PM +0100, Bruno Haible wrote: > Radovan Garabik writes: > > > > From my naive point of view, I would expect isprint() > > to return nonzero for utf-8 locale, since this would allow > > older non-multibyte aware programs using isprint() just to > > pass utf-8 characters to output, which at least has a chance > > of working, instead of not displaying them at all. > > The purpose of calling isprint in such programs is to filter out > control characters, right? Now when you such an old program calls
in theory, yes but often it is used to filter out characters that should not go straight to the terminal, where they can be a source of a DOS attack (colour codes, switching terminal into graphics mode, backspaces - I happened to be a victim of such a joke a long time ago). > isprint on the individual bytes that constitute a multibyte character, > is cannot know whether that character is a graphic character (like > U+20AC) or a control character (like U+200E). Blindly returning 1 > would work in some cases but not in others. The problemin this case is, which characters should be passed to the terminal and which not. RTL mark obviously should, since it is a major component of text formatting layout and without it the text would look much different than intended (if we assume we have satisfactory working bidi terminal), but one can argue that ANSI colour sequences and linefeeds also make a part of text layout. And stray RTL mark can be also a rather good mean of a DOS attack. > > Better is to port the application to use mbrtowc and iswprint. > Depends on the application I think - what I have in mind now is finger client, with things like usernames and .plan files in UTF-8 (btw the current bsd/linux finger implementation is rather broken, it does not even use isprint() to decide which characters are printable, but assumes that everything found in ASCII + ISO-latin + koi8-r is printable and everything else is not). Of course, a malicious user should not be able to break remote terminal with his carefully prepared evil .plan file... -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ melkor.dnp.fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! -- Linux-UTF8: i18n of Linux on all levels Archive: http://mail.nl.linux.org/linux-utf8/