bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] patch: Improve the rolling file name length for downloadi


From: Andries E. Brouwer
Subject: Re: [Bug-wget] patch: Improve the rolling file name length for downloading progress image when without NLS
Date: Fri, 17 Feb 2017 13:41:38 +0100
User-agent: Mutt/1.5.24 (2015-08-30)

On Fri, Feb 17, 2017 at 09:48:23AM +0100, Tim Ruehsen wrote:

> @Andries Do you know an algorithm how to calculate the columns from a given 
> string + encoding ?

Hi Tim,

In principle, yes. But there are many encodings.

I have not read the surrounding conversation, but assume that
the question is about how to do this rotating filename
if the current locale uses an arbitrary encoding.

First do the conversion of the string to the current locale.
Then find out how wide things will be, and where possible
cut points are.

If the current locale uses Unicode then finding the allowed
cut points is easy: all non-first bytes start with bits 10...
while all first bytes start 0... or 11...

Finding the width of a displayed symbol is not very difficult,
but there is no 100% solution. The problem is that it depends
on the installed fonts. The expected width for unicode symbols
requires tables, and wget already has them, near uc_width().

So the unicode part is straightforward. Other encodings are messy.
For SJIS and similar multi-byte character sets one can have
(per character set) descriptions of which codes are single-byte
and which double-byte, and how wide the resulting symbol is.
For ISO 2022 type encoding, with embedded escape sequences,
life is more difficult.

Andries



reply via email to

[Prev in Thread] Current Thread [Next in Thread]