CC to vim_dev
On Thu, Jun 5, 2014 at 2:50 AM, Stas Malavin <[email protected]> wrote:
> To make changes in several files I use the following script:
>
> echo search('publications.html"') | normal o<li><a
> href="./book_series.html">Книжные серии</a></li>
> echo search('collections.html"') | d
> echo search('photo.html"') | d
> wq
>
> Then I do
> for file in *.html do; vim -e $file < script; done
>
> As a result a string "^Z=86=K5 A5@88" is inserted instead of "Книжные
> серии". All html files as well as the script itself are utf-8 encoded, and
> no other problems with Cyrillic revealed. What's going on?
>
> Thanks in advance for any comment!
In Ex mode, multi-byte character is not handled.
Please check the attached patch.
--
Yukihiro Nakadaira - [email protected]
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff -r bed71c37618c src/ex_getln.c
--- a/src/ex_getln.c Thu May 29 14:36:29 2014 +0200
+++ b/src/ex_getln.c Thu Jun 05 22:30:34 2014 +0900
@@ -2188,6 +2188,7 @@
int vcol = 0;
char_u *p;
int prev_char;
+ int len;
/* Switch cursor on now. This avoids that it happens after the "\n", which
* confuses the system function that computes tabstops. */
@@ -2264,7 +2265,17 @@
{
if (line_ga.ga_len > 0)
{
- --line_ga.ga_len;
+#ifdef FEAT_MBYTE
+ if (has_mbyte)
+ {
+ p = (char_u *)line_ga.ga_data;
+ p[line_ga.ga_len] = NUL;
+ len = (*mb_head_off)(p, p + line_ga.ga_len - 1) + 1;
+ line_ga.ga_len -= len;
+ }
+ else
+#endif
+ --line_ga.ga_len;
goto redraw;
}
continue;
@@ -2300,8 +2311,9 @@
/* redraw the line */
msg_col = startcol;
vcol = 0;
- for (p = (char_u *)line_ga.ga_data;
- p < (char_u *)line_ga.ga_data + line_ga.ga_len; ++p)
+ p = (char_u *)line_ga.ga_data;
+ p[line_ga.ga_len] = NUL;
+ while (p < (char_u *)line_ga.ga_data + line_ga.ga_len)
{
if (*p == TAB)
{
@@ -2309,11 +2321,14 @@
{
msg_putchar(' ');
} while (++vcol % 8);
+ ++p;
}
else
{
- msg_outtrans_len(p, 1);
- vcol += char2cells(*p);
+ len = MB_PTR2LEN(p);
+ msg_outtrans_len(p, len);
+ vcol += ptr2cells(p);
+ p += len;
}
}
msg_clr_eos();
@@ -2362,7 +2377,15 @@
if (IS_SPECIAL(c1))
c1 = '?';
- ((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1;
+#ifdef FEAT_MBYTE
+ if (has_mbyte)
+ len = (*mb_char2bytes)(c1, (char_u *)line_ga.ga_data +
line_ga.ga_len);
+ else
+#endif
+ {
+ len = 1;
+ ((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1;
+ }
if (c1 == '\n')
msg_putchar('\n');
else if (c1 == TAB)
@@ -2376,10 +2399,10 @@
else
{
msg_outtrans_len(
- ((char_u *)line_ga.ga_data) + line_ga.ga_len, 1);
+ ((char_u *)line_ga.ga_data) + line_ga.ga_len, len);
vcol += char2cells(c1);
}
- ++line_ga.ga_len;
+ line_ga.ga_len += len;
escaped = FALSE;
windgoto(msg_row, msg_col);