1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-02 03:46:21 -04:00

Bug 921, add_document_to_string: Fixed the UTF-8 half of the code.

* Recompute the pos variable for each cell, rather than just once per line.
  This fixes the bug that only the first cell was being examined.

* Moved the bulk of the code outside the "if (frame && data >= 176 &&
  data < 224)" conditional.  This fixes the bug that only frame
  characters were being added to the string.

* If the cell has UCS_NO_CHAR in it, don't add that to the string.

* Call encode_utf8 even for characters that originated from a frame.
  This does not matter yet but will be correct if the function is
  later changed to use the Unicode line-drawing characters for frames.
This commit is contained in:
Kalle Olavi Niemitalo 2007-01-07 00:09:34 +02:00 committed by Kalle Olavi Niemitalo
parent 3bee1cbfc4
commit f796051b4c

View File

@ -397,33 +397,34 @@ add_document_to_string(struct string *string, struct document *document)
goto end;
utf8:
for (y = 0; y < document->height; y++) {
struct screen_char *pos = document->data[y].chars;
int white = 0;
int x;
for (x = 0; x < document->data[y].length; x++) {
struct screen_char *pos = &document->data[y].chars[x];
unicode_val_T data = pos->data;
unsigned int frame = (pos->attr & SCREEN_ATTR_FRAME);
if (!isscreensafe(data)) {
white++;
continue;
} else if (frame && data >= 176 && data < 224) {
data = frame_dumb[data - 176];
} else {
if (frame && data >= 176 && data < 224)
data = frame_dumb[data - 176];
if (data <= ' ') {
/* Count spaces. */
white++;
} else if (data == UCS_NO_CHAR) {
/* This is the second cell of
* a double-cell character. */
} else {
/* Print spaces if any. */
if (white) {
add_xchar_to_string(string, ' ', white);
white = 0;
}
if (frame)
add_char_to_string(string, data);
else
add_to_string(string, encode_utf8(data));
add_to_string(string, encode_utf8(data));
}
}
}