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

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

How to replace a string to Unicode escape?


From: ptmono
Subject: How to replace a string to Unicode escape?
Date: Mon, 16 Nov 2009 23:46:27 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

A program returns a unicode value "%uc0ac%ub791". The value can be the
combination of unicode with ascii. For example "%uc0ac%ub791 sarang
%uc0ac%ub791".

The function string-to-multibyte can be used to return the string.

,----
| (string-to-multibyte "\uc0ac\ub791 sarang \uc0ac\ub791")
| "사랑 sarang 사랑"
`----

The *problem* is that how to replace "%" to "\" or "%u" to "\u".

How can return the string from the value?

Thanks



P.S

,----
| (string-to-multibyte "\\uc0ac\\ub791 sarang \\uB098\\uB2E4")
| "\\uc0ac\\ub791 sarang \\uB098\\uB2E4"
| 
| (replace-regexp-in-string "%u" "\\u" "%uc0ac%ub791 sarang %uc0ac%ub791")
| ->>>(error "Invalid use of `\\' in replacement text")
| 
| (replace-regexp-in-string "%" "\\\\" "%uc0ac%ub791 sarang %uc0ac%ub791")
| "\\uc0ac\\ub791 sarang \\uc0ac\\ub791"
`----





reply via email to

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