Permalink
Browse files

Remove base64 encoding

References #17
  • Loading branch information...
1 parent f3de5f9 commit 44e06d4b0eded1fd06eeaa47e36276dd4dd911e4 @tpope committed Jan 13, 2013
Showing with 0 additions and 60 deletions.
  1. +0 −60 plugin/unimpaired.vim
View
60 plugin/unimpaired.vim
@@ -208,64 +208,6 @@ function! s:url_decode(str)
return substitute(str,'%\(\x\x\)','\=nr2char("0x".submatch(1))','g')
endfunction
-let s:base64_chars = map(range(char2nr('A'),char2nr('Z')),'nr2char(v:val)')
- \ + map(range(char2nr('a'),char2nr('z')),'nr2char(v:val)')
- \ + map(range(char2nr('0'),char2nr('9')),'nr2char(v:val)')
- \ + ['+','/']
-
-let s:base64_filler = '='
-let s:base64_lookup = {}
-let s:pos = 0
-for s:char in s:base64_chars
- let s:base64_lookup[s:char] = s:pos
- let s:pos += 1
-endfor
-unlet s:pos
-
-function! s:base64_encode(str)
- " Respect current file encoding
- let input = a:str
- let encoded = ''
- while len(input) > 2
- let encoded .= s:base64_chars[char2nr(input[0])/4]
- \ . s:base64_chars[16*(char2nr(input[0])%4 )+char2nr(input[1])/16]
- \ . s:base64_chars[4 *(char2nr(input[1])%16)+char2nr(input[2])/64]
- \ . s:base64_chars[char2nr(input[2])%64]
- let input = input[3:]
- endwhile
- if len(input) == 2
- let encoded .= s:base64_chars[char2nr(input[0])/4]
- \ . s:base64_chars[16*(char2nr(input[0])%4 )+char2nr(input[1])/16]
- \ . s:base64_chars[4 *(char2nr(input[1])%16)]
- \ . s:base64_filler
- elseif len(input) == 1
- let encoded .= s:base64_chars[char2nr(input[0])/4]
- \ . s:base64_chars[16*(char2nr(input[0])%4 )]
- \ . s:base64_filler
- \ . s:base64_filler
- endif
- return encoded
-endfunction
-
-function! s:base64_decode(str)
- if len(a:str) % 4 != 0
- return a:str
- endif
- let input = a:str
- let decoded = ''
- while !empty(input)
- let decoded .= nr2char(4 * s:base64_lookup[input[0]] + (s:base64_lookup[input[1]] / 16))
- if input[2] !=# s:base64_filler
- let decoded .= nr2char(16 * (s:base64_lookup[input[1]] % 16) + (s:base64_lookup[input[2]]/4))
- if input[3] !=# s:base64_filler
- let decoded .= nr2char(64 * (s:base64_lookup[input[2]] % 4) + s:base64_lookup[input[3]])
- endif
- endif
- let input = input[4:]
- endwhile
- return decoded
-endfunction
-
" HTML entities {{{2
let g:unimpaired_html_entities = {
@@ -415,8 +357,6 @@ call UnimpairedMapTransform('url_encode','[u')
call UnimpairedMapTransform('url_decode',']u')
call UnimpairedMapTransform('xml_encode','[x')
call UnimpairedMapTransform('xml_decode',']x')
-call UnimpairedMapTransform('base64_encode','[Y')
-call UnimpairedMapTransform('base64_decode',']Y')
" }}}1

0 comments on commit 44e06d4

Please sign in to comment.