Created
February 18, 2013 10:35
-
-
Save heavenshell/4976504 to your computer and use it in GitHub Desktop.
Decode unicode escape string to utf-8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let s:save_cpo = &cpo | |
set cpo&vim | |
python << PYTHONEOF | |
import vim | |
def unicode_escape(): | |
start = vim.eval('start') | |
end = vim.eval('end') | |
line = vim.eval('val') | |
string = line[int(start) - 1:int(end)] | |
print string.decode('unicode_escape').encode('utf-8') | |
PYTHONEOF | |
function! UnicodeEscapeDecode() range | |
let start = col("'<") | |
let end = col("'>") | |
let val = getline('.') | |
python unicode_escape() | |
endfunction | |
let &cpo = s:save_cpo | |
unlet s:save_cpo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment