mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05: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:
parent
3bee1cbfc4
commit
f796051b4c
@ -397,32 +397,33 @@ add_document_to_string(struct string *string, struct document *document)
|
|||||||
goto end;
|
goto end;
|
||||||
utf8:
|
utf8:
|
||||||
for (y = 0; y < document->height; y++) {
|
for (y = 0; y < document->height; y++) {
|
||||||
struct screen_char *pos = document->data[y].chars;
|
|
||||||
int white = 0;
|
int white = 0;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
for (x = 0; x < document->data[y].length; 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;
|
unicode_val_T data = pos->data;
|
||||||
unsigned int frame = (pos->attr & SCREEN_ATTR_FRAME);
|
unsigned int frame = (pos->attr & SCREEN_ATTR_FRAME);
|
||||||
|
|
||||||
if (!isscreensafe(data)) {
|
if (!isscreensafe(data)) {
|
||||||
white++;
|
white++;
|
||||||
continue;
|
continue;
|
||||||
} else if (frame && data >= 176 && data < 224) {
|
} else {
|
||||||
|
if (frame && data >= 176 && data < 224)
|
||||||
data = frame_dumb[data - 176];
|
data = frame_dumb[data - 176];
|
||||||
|
|
||||||
if (data <= ' ') {
|
if (data <= ' ') {
|
||||||
/* Count spaces. */
|
/* Count spaces. */
|
||||||
white++;
|
white++;
|
||||||
|
} else if (data == UCS_NO_CHAR) {
|
||||||
|
/* This is the second cell of
|
||||||
|
* a double-cell character. */
|
||||||
} else {
|
} else {
|
||||||
/* Print spaces if any. */
|
/* Print spaces if any. */
|
||||||
if (white) {
|
if (white) {
|
||||||
add_xchar_to_string(string, ' ', white);
|
add_xchar_to_string(string, ' ', white);
|
||||||
white = 0;
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user