vim - expression to transform unicode codepoint to character -
i've got file has escaped unicode in it:
blah blah blah \u2192 blah blah blah
i'd transform unicode escapes actual characters search/replace:
:%s/\\u\(\d\{4}\)/\=codepointtocharacter(submatch(1))/g
though know how transform codepoint character in insert mode (ctrl-v u 2192
→), don't know how transformation in viml expression.
do need write custom function, or there builtin or plugin can use?
you can first use str2nr()
convert number hex, use nr2char
display char.
extend command little bit:
%s/\\u\(\x\{4}\)/\=nr2char(str2nr(submatch(1),16))/g
Comments
Post a Comment