Quantcast

Translate \u0041 to A

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Translate \u0041 to A

JohnBeckett
Given this text:

A\u0042C\u0044E

What substitute changes it to:

ABCDE

John

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Translate \u0041 to A

Christian Brabandt
On Sa, 25 Mär 2017, JohnBeckett wrote:

> Given this text:
>
> A\u0042C\u0044E
>
> What substitute changes it to:
>
> ABCDE

Something like this:
:%s/\\u\(\x\{4\}\)/\=nr2char('0x'.submatch(1),1)/g

or with a function like this:

func! String(match)
    exe 'return "'.a:match.'"'
endfunc

And then:
:%s/\\u\x\{4\}/\=String(submatch(0))/g

Best,
Christian
--
Abschied nehmen ist immer schmerzlich, selbst wenn es nur für kurze
Zeit ist.
                -- Anne Morrow Lindbergh (Muscheln in meiner Hand)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Translate \u0041 to A

JohnBeckett
On Saturday, March 25, 2017 at 9:32:11 PM UTC+11, Christian Brabandt wrote:

>> A\u0042C\u0044E
>>
>> What substitute changes it to:
>>
>> ABCDE
>
> Something like this:
> :%s/\\u\(\x\{4\}\)/\=nr2char('0x'.submatch(1),1)/g
>
> or with a function like this:
>
> func! String(match)
>     exe 'return "'.a:match.'"'
> endfunc
>
> And then:
> :%s/\\u\x\{4\}/\=String(submatch(0))/g
Thanks, I started well but got entirely lost.

John

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...