mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Merge branch '3783_mcview_invalid_utf8'
* 3783_mcview_invalid_utf8: Ticket #3783: mcview: fix interpretation of invalid utf-8 symbols.
This commit is contained in:
commit
ed0ed4ac72
@ -341,6 +341,8 @@ mcview_char_display (const WView * view, int c, char *s)
|
||||
* Normally: stores c, updates state, returns TRUE.
|
||||
* At EOF: state is unchanged, c is undefined, returns FALSE.
|
||||
*
|
||||
* Just as with mcview_get_utf(), invalid UTF-8 is reported using negative integers.
|
||||
*
|
||||
* Also, temporary hack: handle force_max here.
|
||||
* TODO: move it to lower layers (datasource.c)?
|
||||
*/
|
||||
|
@ -147,6 +147,8 @@ mcview_get_ptr_file (WView * view, off_t byte_index)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Invalid UTF-8 is reported as negative integers (one for each byte),
|
||||
* see ticket 3783. */
|
||||
gboolean
|
||||
mcview_get_utf (WView * view, off_t byte_index, int *ch, int *ch_len)
|
||||
{
|
||||
@ -200,7 +202,8 @@ mcview_get_utf (WView * view, off_t byte_index, int *ch, int *ch_len)
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
*ch = (unsigned char) (*str);
|
||||
/* Implicit conversion from signed char to signed int keeps negative values. */
|
||||
*ch = *str;
|
||||
*ch_len = 1;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user