Skip to content

Commit

Permalink
use built-in base64_encode if available
Browse files Browse the repository at this point in the history
  • Loading branch information
Konfekt authored Dec 30, 2024
1 parent 4b068e5 commit f69a2f0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugin/oscyank.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

" -------------------- INIT --------------------------------
if exists('g:loaded_oscyank')
finish
Expand Down Expand Up @@ -38,6 +39,12 @@ function s:echo(text, hl)
echohl None
endfunction

if exists(*base64_encode')
function s:encode_b64(str, size)
return a:size <= 0 ?
\ base64_encode(a:str) : strpart(base64_encode(a:str), a:size)
endfunction
else
function s:encode_b64(str, size)
let bytes = map(range(len(a:str)), 'char2nr(a:str[v:val])')
let b64 = []
Expand Down Expand Up @@ -74,6 +81,7 @@ function s:encode_b64(str, size)

return chunked
endfunction
endif

function s:get_text(mode, type)
" Save user settings
Expand Down

0 comments on commit f69a2f0

Please sign in to comment.