vim-patch:9.0.1598: screenchar() and others are wrong with DBCS 'encoding' (#23872)

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 vim/vim#12469)

47eec6716b
This commit is contained in:
zeertzjq
2023-06-02 04:31:17 +08:00
committed by GitHub
parent 7ade44fefe
commit a0375b68c1
4 changed files with 61 additions and 10 deletions

View File

@@ -138,8 +138,9 @@ void grid_putchar(ScreenGrid *grid, int c, int row, int col, int attr)
grid_puts(grid, buf, row, col, attr);
}
/// get a single character directly from grid.chars into "bytes[]".
/// Also return its attribute in *attrp;
/// Get a single character directly from grid.chars into "bytes", which must
/// have a size of "MB_MAXBYTES + 1".
/// If "attrp" is not NULL, return the character's attribute in "*attrp".
void grid_getbytes(ScreenGrid *grid, int row, int col, char *bytes, int *attrp)
{
grid_adjust(&grid, &row, &col);
@@ -150,7 +151,9 @@ void grid_getbytes(ScreenGrid *grid, int row, int col, char *bytes, int *attrp)
}
size_t off = grid->line_offset[row] + (size_t)col;
*attrp = grid->attrs[off];
if (attrp != NULL) {
*attrp = grid->attrs[off];
}
schar_copy(bytes, grid->chars[off]);
}