Insure correct UTF-8 encoding: asc( chr( 0x800)) == 0x800.

buffer-position displays unicode value of character under cursor instead of first byte of unicode sequence.
This commit is contained in:
Renaud 2015-02-06 13:20:51 +08:00
parent 4cbf1e9ae1
commit 2cef071492
2 changed files with 7 additions and 4 deletions

View File

@ -73,7 +73,7 @@ int showcpos(int f, int n)
int numlines; /* # of lines in file */
long predchars; /* # chars preceding point */
int predlines; /* # lines preceding point */
int curchar; /* character under cursor */
unicode_t curchar ; /* character under cursor */
int ratio;
int col;
int savepos; /* temp save for current offset */
@ -91,12 +91,15 @@ int showcpos(int f, int n)
while (lp != curbp->b_linep) {
/* if we are on the current line, record it */
if (lp == curwp->w_dotp) {
int len ;
predlines = numlines;
predchars = numchars + curwp->w_doto;
if ((curwp->w_doto) == llength(lp))
len = llength( lp) ;
if( (curwp->w_doto) == len)
curchar = '\n';
else
curchar = lgetc(lp, curwp->w_doto);
(void) utf8_to_unicode( lp->l_text, curwp->w_doto, len, &curchar) ;
}
/* on to the next line */
++numlines;

2
utf8.c
View File

@ -97,7 +97,7 @@ unsigned unicode_to_utf8(unsigned int c, char *utf8)
bytes++;
prefix >>= 1;
c >>= 6;
} while (c > prefix);
} while( c >= prefix) ;
*p = c - 2*prefix;
reverse_string(utf8, p);
}