Is there a shortcut key in Ecplise that allows to replace an special character (accented) by its unicode escape sequence (\uXXXX)?

- 4,176
- 7
- 47
- 81

- 15,044
- 7
- 62
- 88
-
I was looking for a shortcut key, not a plugin. But, no problem, now it's upvoted. – Italo Borssatto Jan 21 '13 at 10:41
4 Answers
As an alternative, you can use java editor templates (see Eclipse Preferences -> Java -> Editor -> Templates) and add a template for each special character that you want to replace. For example:
Name: ö
Context: Java
Automatically insert: true
Pattern: \u00F6
Now hit ctrl-space after an occurence of 'ö' in the source code, this will pop up a context menu allowing you to replace it with the unicode escape sequence.

- 324
- 3
- 7
There is a plugin with two text fields for simultaneous escaping to and from unicode.

- 4,176
- 7
- 47
- 81
I don't think there is.
The best I can suggest is to run your source files through the native2ascii
from the command line. (And then "Refresh" ... )

- 698,415
- 94
- 811
- 1,216
-
1Yes, yesterday I've passed by all the shortcuts, using ctrl+shif+L. I decided to use UTF-8 in all files in my project. – Italo Borssatto Apr 07 '11 at 22:56
You didn't tell if you are using Eclipse with Java - in case you are and if you have at some point installed Windowbuilder
as well, you can use its automatic code generation to quickly replace all occurrences of special/accented characters within some text with their unicode representation.
Just create some dummy GUI object in Design view
(e.g. JLabel
), type the string into the text
property and you'll get all special characters automatically unicode escaped after switching back to the Source view
.
In case you are working in non-Java environment you might keep anoter instance of Eclipse opened - as a handy unicode-escaping-converter.

- 698
- 1
- 7
- 21
-
The plugin unicode-escape-eclipse suggested by Martin doesn't require two Eclipse instances. – Italo Borssatto Aug 10 '16 at 10:54