help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to replace a string to Unicode escape?


From: ptmono
Subject: Re: How to replace a string to Unicode escape?
Date: Tue, 17 Nov 2009 12:24:50 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

Thanks.


harven <harven@free.fr> writes:
> Here is a ugly hack (use at your own risk)
>
> (defun my-ucs (arg)
>   "return unicode character \\uxxxx from string \"%uxxxx\" or return \"\".
>    probably fails badly if xxx is not a valid hex code"
>     (or 
>       (char-to-string
>         (decode-char 'ucs
>                (string-to-number
>                    (substring arg 2) 16)))
>       ""))
>
> (replace-regexp-in-string 
>      "%u...."
>      'my-ucs
>      "%uc0ac%ub791 sarang %uc0ac%ub791")
>
>  -->  "사랑 sarang 사랑"
>
> Cheers




reply via email to

[Prev in Thread] Current Thread [Next in Thread]