[prev in list] [next in list] [prev in thread] [next in thread]
List: vim
Subject: Re: multibyte in patterns
From: Benji Fisher <benji () member ! AMS ! org>
Date: 2002-12-31 20:19:34
[Download RAW message or body]
Bram Moolenaar wrote:
> Benji Fisher wrote:
>
>
>> More multi-byte woes. If 'encoding' is set to utf-8, then a MB
>>character does not match itself!
>>
>>:let foo = "\xab"
>>:set enc?
>> encoding=latin1
>>:echo foo =~ foo
>>1
>>:set enc=utf8
>>:set enc?
>> encoding=utf-8
>>:echo foo =~ foo
>>0
>>
>>Is this expected, or is it a bug? Is there a work-around? Am I
>>supposed to do this?
>>
>>:echo iconv(foo, 'latin1', &enc) =~ foo
>>1
>
> Changing 'encoding' makes multi-byte characters in registers and
> variables invalid. Although you would still expect "foo =~ foo" to
> work. The reason it doesn't is that the 0xab byte is an invalid
> character, it doesn't match anything.
Thanks for the reply. This has been bothering me for a while, and
I do not think anyone else can help with it.
The problem is not caused by changing 'encoding' after assigning
the variable. I can try
:set encoding?
utf-8
:let foo = "\xab"
:echo foo =~ foo
0
I would like to have a script insert a character like the one
given by the digraph "<C-K><<". According to "ga" (Normal mode) this
character has code 0xab , so I try
:let foo = "\xab"
:put=foo
and this inserts a single character that looks like "<ab>". Then I try
:let foo = iconv("\xab", "latin1", &enc)
:put=foo
and I get the "<<" digraph. Strangely, "ga" tells me these are both
"Hex 00ab".
Are the tricks with iconv() supposed to work? Is there a simpler way?
--Benji Fisher
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic