From f796051b4c45436e1b64aef7fca05dabb5cf8d52 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 7 Jan 2007 00:09:34 +0200 Subject: [PATCH] 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. --- src/viewer/dump/dump.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/viewer/dump/dump.c b/src/viewer/dump/dump.c index f042df6e..ab3c170d 100644 --- a/src/viewer/dump/dump.c +++ b/src/viewer/dump/dump.c @@ -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)); } } }