Skip to content

Commit 80bb6dd

Browse files
committed
fix: avoid converting while url encoding
refer: #395
1 parent 8cc3f58 commit 80bb6dd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

autoload/wiki/url/utils.vim

+3-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function! wiki#url#utils#url_encode(str) abort
154154
" This code is based on Tip Pope's vim-unimpaired:
155155
" https://github.com/tpope/vim-unimpaired
156156
return substitute(
157-
\ iconv(a:str, 'latin1', 'utf-8'),
157+
\ a:str,
158158
\ '[^A-Za-z0-9_.~-]',
159159
\ '\="%".printf("%02X",char2nr(submatch(0)))',
160160
\ 'g'
@@ -170,13 +170,12 @@ function! wiki#url#utils#url_decode(str) abort
170170
\ substitute(a:str, '%0[Aa]\n$', '%0A', ''),
171171
\ '%0[Aa]', '\n', 'g'),
172172
\ '+', ' ', 'g')
173-
let l:str = substitute(l:str, '%\(\x\x\)', '\=nr2char("0x".submatch(1))', 'g')
174-
return iconv(str, 'utf-8', 'latin1')
173+
return substitute(l:str, '%\(\x\x\)', '\=nr2char("0x".submatch(1))', 'g')
175174
endfunction
176175

177176
function! wiki#url#utils#url_encode_specific(str, chars) abort
178177
return substitute(
179-
\ iconv(a:str, 'latin1', 'utf-8'),
178+
\ a:str,
180179
\ '[' .. a:chars .. ']',
181180
\ '\="%"..printf("%02X", char2nr(submatch(0)))',
182181
\ 'g'

0 commit comments

Comments
 (0)