I am currently using python -m base64 to convert text in vim buffer to base64.
I have tried to replace it with a new built-in function but it looks like it can't handle some of utf-8:
echo base64_encode(list2blob(str2list("tab:›\ ,nbsp:␣,trail:·,extends:…,precedes:… showbreak=↪", true)))
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Isn't the problem here that you can't easily convert a String to a Blob?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Isn't the problem here that you can't easily convert a String to a Blob?
It is, however the goal is to convert buffer text to base64. List to blob function may work as designed but not necessarily fit for the base64 encode function.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
I am currently using
python -m base64to convert text in vim buffer to base64.
I have tried to replace it with a new built-in function but it looks like it can't handle some of utf-8:
echo base64_encode(list2blob(str2list("tab:›\ ,nbsp:␣,trail:·,extends:…,precedes:… showbreak=↪", true)))
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I am currently using
python -m base64to convert text in vim buffer to base64.I have tried to replace it with a new built-in function but it looks like it can't handle some of utf-8:
echo base64_encode(list2blob(str2list("tab:›\ ,nbsp:␣,trail:·,extends:…,precedes:… showbreak=↪", true)))
:echo iconv('tab:›\ ,nbsp:␣,trail:·,extends:…,precedes:… showbreak=↪', 'latin1', &encoding)->str2list()->list2blob()->base64_encode()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.![]()
On Wed, Jan 1, 2025 at 6:50 AM Yegappan Lakshmanan @.***> wrote:
I have now made these functions work with Unicode strings. I will send out a PR later. - Yegappan
function! Str2Blob(str) abort return iconv(a:str, 'latin1', &encoding)->str2list()->list2blob() endfunction function! Blob2Str(blob) abort return blob2list(a:blob)->list2str()->iconv(&encoding, 'latin1') endfunction
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.![]()
That is a clever trick to force reading byte values. But I would think having separate functions is a bit cleaner.
And it is a bit of an overhead to invoke the iconv() function, when it is not needed yet. And it seems the iconv() function may not always be available. :h +iconv, mentions this is system dependent.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
But I would think having separate functions is a bit cleaner.
Rather an improved version of str2list / list2str. Having also an extra function, such as str2blob is really optional.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
Do you use “!python -m base64” to base64 encode the text in the current buffer?
More or less: https://asciinema.org/a/GLIRVXXjvhfKzCxoSDA1pZem9
I have now made these functions work with Unicode strings. I will send out a PR later.
Great, thank you!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Please try these out and let me know if you have any problems in using these functions.
Works fine, however a tiny bit different to the python -m base64 -- probably no big deal -- it adds newlines whereas base64_encode() doesn't.
https://asciinema.org/a/wybRstcNg6jHX0x4T1mFXmBxl
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
it adds newlines whereas
base64_encode()
ok, this is expected
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
Closed #16355 as completed.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
This is fixed
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()