2

To keep code clean across different platforms (and due to a bug where one can't use Unicode escape literals like 😁 in XML files), instead of putting actual "non-normal" Unicode characters like U+1F601 (), I usually use \u-escaped UTF-16 surrogate pairs like \ud83d\ude01.

However, when I select and copy String literals containing these escapes from a Java source code file, they are converted to the actual character upon pasting. So when I copy and paste the text

String smile = "\ud83d\ude01";

to another location, it comes out as

String smile = "";

How can I disable this behavior? I didn't find anything in the Settings; or I searched in the wrong place.

s3lph
  • 4,575
  • 4
  • 21
  • 38
  • That is JAVA, right? Those two lines by definition have exactly the same meaning. Are you storing that source code in an XML file? – roeland Feb 12 '16 at 04:17
  • No it's a java source code file. Why would I store Java code in an XML? I know they have the same meaning for the compiler/the JVM, but I don't want the IDE to convert the escape sequences. – s3lph Feb 12 '16 at 09:21
  • Fair enough, but then using `\u` escapes doesn't work around any bugs involving putting characters in XML. I think it is safe, even across different platforms, to use a literal `""``, as long as you consistently encode source files as UTF-8 or UTF-16 (and set up that encoding in your project / encoding settings). For XML, encode it as UTF-8 and also just use a literal . I don't know why the IDE would *auto-convert* those escapes though, or how to switch it off. – roeland Feb 13 '16 at 05:27
  • No, I can't paste it in the XML. Due to a strange implementation on UTF-8 XML parsing, the app compiles but crashes when loading the layout file on pre-Marshmallow, i.e. at least 90% of the devices: http://stackoverflow.com/a/16789981/2033332 – s3lph Feb 13 '16 at 09:13

1 Answers1

2

I have not found an option that disables it when pasting; instead, I use the "Paste Simple" option to prevent the escaped Unicode from converting to the actual character.

On a Mac, the keyboard combination for "Paste Simple" is +alt+shift+V

curious_george
  • 622
  • 2
  • 8
  • 19