patch 9.0.1598: screenchar() and others are wrong with DBCS 'encoding'
Problem: screenchar(), screenchars() and screenstring() do not work
properly when 'encoding' is set to a double-byte encoding.
Solution: Fix the way the bytes of the characters are obtained.
(issue #12469)
diff --git a/src/screen.c b/src/screen.c
index e9bc792..7966f3b 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1199,8 +1199,9 @@
}
/*
- * Get a single character directly from ScreenLines into "bytes[]".
- * Also return its attribute in *attrp;
+ * Get a single character directly from ScreenLines into "bytes", which must
+ * have a size of "MB_MAXBYTES + 1".
+ * If "attrp" is not NULL, return the character's attribute in "*attrp".
*/
void
screen_getbytes(int row, int col, char_u *bytes, int *attrp)
@@ -1212,7 +1213,8 @@
return;
off = LineOffset[row] + col;
- *attrp = ScreenAttrs[off];
+ if (attrp != NULL)
+ *attrp = ScreenAttrs[off];
bytes[0] = ScreenLines[off];
bytes[1] = NUL;