Ticket #2372 (Editor sometimes shows multibyte UTF-8 chars as two dots)
Sometimes when text contain multibyte UTF-8 chars, editor shows two dots instead of some letter. When moving text cursor after that letter it will be displayed properly. When moving cursor back (before letter) it will be displayed again as two dots. Signed-off-by: Ilia Maslakov <il.smind@gmail.com> added UTF8_CHAR_LEN Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
Этот коммит содержится в:
родитель
8fd8c23a49
Коммит
3e1b644f41
@ -128,6 +128,7 @@
|
|||||||
#define SCRIPT_SUFFIX ""
|
#define SCRIPT_SUFFIX ""
|
||||||
#define get_default_editor() "vi"
|
#define get_default_editor() "vi"
|
||||||
#define OS_SORT_CASE_SENSITIVE_DEFAULT 1
|
#define OS_SORT_CASE_SENSITIVE_DEFAULT 1
|
||||||
|
#define UTF8_CHAR_LEN 6
|
||||||
|
|
||||||
/* C++ style type casts */
|
/* C++ style type casts */
|
||||||
#define const_cast(m_type, m_expr) ((m_type) (m_expr))
|
#define const_cast(m_type, m_expr) ((m_type) (m_expr))
|
||||||
|
@ -1949,6 +1949,7 @@ edit_get_utf (WEdit * edit, long byte_index, int *char_width)
|
|||||||
gunichar ch;
|
gunichar ch;
|
||||||
gchar *next_ch = NULL;
|
gchar *next_ch = NULL;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
gchar utf8_buf[UTF8_CHAR_LEN + 1];
|
||||||
|
|
||||||
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
|
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
|
||||||
{
|
{
|
||||||
@ -1966,6 +1967,17 @@ edit_get_utf (WEdit * edit, long byte_index, int *char_width)
|
|||||||
|
|
||||||
res = g_utf8_get_char_validated (str, -1);
|
res = g_utf8_get_char_validated (str, -1);
|
||||||
|
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
/* Retry with explicit bytes to make sure it's not a buffer boundary */
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < UTF8_CHAR_LEN; i++)
|
||||||
|
utf8_buf[i] = edit_get_byte (edit, byte_index + i);
|
||||||
|
utf8_buf[UTF8_CHAR_LEN] = '\0';
|
||||||
|
str = utf8_buf;
|
||||||
|
res = g_utf8_get_char_validated (str, -1);
|
||||||
|
}
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
ch = *str;
|
ch = *str;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user