jEdit Community - Resources for users of the jEdit Text Editor
unescape a unicode escape sequence
Submitted by Anonymous on Friday, 4 February, 2005 - 16:27
Hi, I'm trying to convert unicode escape sequences to characters. Can someone recommend a good strategy for writing a macro ( or a BeanShell snippet for use in Search Replace dialog? )?

Basically I want to search for this pattern:

(\\u00[[:alnum:]][[:alnum:]]) which matches things like \u00E9

and I want to replace it with:

new Character( $1 ); where $1 is the match from the pattern search.

Is there a way to do this using SearchReplace? Or do I need to iterate through the lines of the current buffer and do replacements on each line?

Thanks for any tips. jEdit Rules my world!!

-Travis McCauley
Toronto
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
The following worked, but I d
by Anonymous on Fri, 04/02/2005 - 19:43
The following worked, but I don't know how reliable it is:

find: (\\u00[[:alnum:]]{2})
replace: (char)Integer.parseInt(_1.substring(2),16)

-Ollie
 
For CJK use this partially valid regexp
by Anonymous on Fri, 11/02/2005 - 18:10
find:(\\u[[:alnum:]]{4})
replace:(char)Integer.parseInt(_1.substring(2),16)

Obviously this won't work if the char is represented by multiple escaped unicodes.
 
Yes that worked for me too.
by Anonymous on Mon, 07/02/2005 - 19:32
Yes that worked for me too. It seems reliable for everything I was trying to convert.

I realized that the jdk executable native2ascii should also work. But I didn't try it yet.

Thanks for your response,
Travis
 
advance
by fxy228 on Sat, 05/02/2005 - 02:49
 
User login
Browse archives
« March 2015  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
33%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1092
Syndication
file   ver   dls
German Localization light   4.4.2.1   47625
Context Free Art (*.cfdg)   0.31   37586
JBuilder scheme   .001   12139
BBEdit scheme   1.0   11705
R Edit Mode - extensive version   0.1   11698
ColdFusion scheme   1.0   11691
Advanced HTML edit mode   1.0   11156
Matlab Edit Mode   1.0   11016
jEdit XP icons   1.0   10482
XP icons for jEdit   1.1   10217