On Sun, Nov 29, 2020 at 04:21:24PM +0000, Thomas Dupond wrote:
> Hello,
> 
> I'm just starting on exploring vile and I fell on something I
> cannot solve. I was trying to write a macro and while vile
> seems to handle UTF8 really well it doesn't seem to work well
> with the function *insert-string*.
> 
> I can insert "é" but when I use "insert-string é" it prints this
> mess : ᅢᄅ

yes... scripting hasn't been as well-tested as interactive stuff :-(
 
> Any idea on how to solve this ?

Here's a fix for the most common case (it won't handle a special
case where the buffer is non-UTF-8), which should work for you.

also attaching a script I used for testing, e.g.,
        ./configure --enable-trace --with-builtin-filters && make
        ./vile @foo.rc makefile
 
> My locale is :
> 
> LANG=en_GB.UTF-8
> LANGUAGE=en_GB:en
...
 
> I'm on debian 4.19 and I compiled vile-9.8 from source with

9.8's getting a little stale - 9.8u is current.

I put snapshots in github (but have too many concurrent things to
polish off 9.8v)

> 
> ./configure --with-builtin-filters
> 
> And $cfgopts = hypertext,locale,iconv,multibyte,terminfo
> 
> 
> Kind regards,
> 
> Thomas
> 

-- 
Thomas E. Dickey <[email protected]>
https://invisible-island.net
ftp://ftp.invisible-island.net
--- estruct.h	2020/08/23 19:03:03	1.757
+++ estruct.h	2020/11/29 22:41:44
@@ -1316,10 +1316,14 @@
  * True if the buffer contents are in UTF-8 (or -16, -32).
  */
 #if OPT_MULTIBYTE
+#define global_is_utfXX()    ((global_b_val(VAL_FILE_ENCODING) >= enc_UTF8) \
+			   || (global_b_val(VAL_FILE_ENCODING) == enc_LOCALE \
+			    && vl_encoding >= enc_UTF8))
 #define b_is_utfXX(bp)       ((b_val(bp, VAL_FILE_ENCODING) >= enc_UTF8) \
 			   || (b_val(bp, VAL_FILE_ENCODING) == enc_LOCALE \
 			    && vl_encoding >= enc_UTF8))
 #else
+#define global_is_utfXX()    0
 #define b_is_utfXX(bp)       0
 #endif
 
--- insert.c	2015/03/13 10:29:15	1.184
+++ insert.c	2020/11/29 22:44:16
@@ -1039,7 +1039,7 @@
 	while (n--) {
 	    tp = tstring;
 	    while (*tp) {
-		if ((status = inschar(*tp++, &backsp_limit)) != TRUE) {
+		if ((status = inschar(CharOf(*tp++), &backsp_limit)) != TRUE) {
 		    n = 0;
 		    break;
 		}
--- line.c	2019/12/19 09:32:10	1.235
+++ line.c	2020/11/29 22:43:43
@@ -542,7 +542,7 @@
     int nn;
     int mapped;
 
-    if ((c > 127) && b_is_utfXX(curbp)) {
+    if (!global_is_utfXX() && (c > 127) && b_is_utfXX(curbp)) {
 	nbytes = vl_conv_to_utf8(target, (UINT) c, sizeof(target));
     } else if (okCTYPE2(vl_wide_enc) && !vl_mb_is_8bit(c)) {
 	nbytes = 1;
store-procedure oops 
insert-string "é"
~endm
map I ié
map K :setl fk=8bit
map M :oops

Attachment: signature.asc
Description: PGP signature

Reply via email to