Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-08 Thread rameo
Thanks but I still don't understand it. No problem. Hope I'll not have problems with `vim.current.buffer[linenr -1]`. My experience with Python tells me that Python language is much easier then vimscript. Things can be done easier with the many Python modules using less code then in vimscript.

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-08 Thread Nikolay Aleksandrovich Pavlov
2016-03-08 14:03 GMT+03:00 rameo : >> Better `vim.Function('getline')(linenr) > > You seems to know everything in every computer language :) > Yes I use Pyth3 and many times also `vim.current.buffer[linenr-1]` > or things like this `r = vim.current.buffer[startline:endline]` > > To avoid decoding e

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-08 Thread rameo
> Better `vim.Function('getline')(linenr) You seems to know everything in every computer language :) Yes I use Pyth3 and many times also `vim.current.buffer[linenr-1]` or things like this `r = vim.current.buffer[startline:endline]` To avoid decoding errors it is better to switch all these stateme

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-08 Thread Nikolay Aleksandrovich Pavlov
2016-03-08 13:34 GMT+03:00 Nikolay Aleksandrovich Pavlov : > 2016-03-08 13:22 GMT+03:00 rameo : >> Thank you. >> You're right. It is not a question of decoding a list but decoding a string. >> Never did anything before with string encoding. I've got it: I cannot use >> searchpos() to use with pyt

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-08 Thread Nikolay Aleksandrovich Pavlov
2016-03-08 13:22 GMT+03:00 rameo : > Thank you. > You're right. It is not a question of decoding a list but decoding a string. > Never did anything before with string encoding. I've got it: I cannot use > searchpos() to use with python. Searching positions must be done in python > (p.e. finditer

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-08 Thread rameo
Thank you. You're right. It is not a question of decoding a list but decoding a string. Never did anything before with string encoding. I've got it: I cannot use searchpos() to use with python. Searching positions must be done in python (p.e. finditer). BTW I thought that ['encoding'] was a pl

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-08 Thread Nikolay Aleksandrovich Pavlov
2016-03-08 12:23 GMT+03:00 rameo : > Can't find anything on the net about string.encode(vim.options[encoding]). > No info either in Vim documentation: if_pyth > > Let say I create my list "MyPositions" with start/end position of matches > using searchpos() in vim. > > Then in my python code I have

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-08 Thread rameo
Can't find anything on the net about string.encode(vim.options[encoding]). No info either in Vim documentation: if_pyth Let say I create my list "MyPositions" with start/end position of matches using searchpos() in vim. Then in my python code I have to do something like this to convert it to byt

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-07 Thread Nikolay Aleksandrovich Pavlov
2016-03-08 1:32 GMT+03:00 rameo : > >> In Python you are not using *byte* counts, it indexes *unicode >> codepoints*. You may convert unicode Python objects to bytes objects >> by using `string.encode(vim.options['encoding'])`, use >> `.decode(vim.options['encoding'])` to convert back. bytes object

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-07 Thread rameo
> In Python you are not using *byte* counts, it indexes *unicode > codepoints*. You may convert unicode Python objects to bytes objects > by using `string.encode(vim.options['encoding'])`, use > `.decode(vim.options['encoding'])` to convert back. bytes objects are > indexed by bytes. You may also

Re: Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-07 Thread Nikolay Aleksandrovich Pavlov
2016-03-07 14:54 GMT+03:00 rameo : > I use searchpos() to capture start/endcolumns of a matches. > Then I use the results in Python code to transform the text. > > However I noted that latin characters as 'èéàòìù' are counted as 1 byte in > Python but 2 bytes in Vim and the output is not as expect

Is there any way to count all latin characters in utf-8 as 1 byte?

2016-03-07 Thread rameo
I use searchpos() to capture start/endcolumns of a matches. Then I use the results in Python code to transform the text. However I noted that latin characters as 'èéàòìù' are counted as 1 byte in Python but 2 bytes in Vim and the output is not as expected. Is there any way to resolve this proble