Last active
January 1, 2016 05:19
-
-
Save Dinnerbone/8098147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Foo { | |
public static void main(String[] args) { | |
String x = "This is weird: \u0022\u003B\u0069\u006E\u0074\u0020\u0079\u003D\u0031\u002F\u0030\u003B\u0078\u003D\u0022???"; | |
System.out.println("x = " + x); | |
} | |
} |
Java supports non-ASCII for names of variables, classes and so forth. If you receive files from some developer with non-ASCII name in them which you don't want to corrupt, using native2ascii is one (dodgy, IMO) option you have to convert it to a plain ASCII file which compiles to the same result. Because Sun wanted to support this, Unicode escapes work anywhere, not just inside strings.
The fact that they also work for encoding basic stuff like double quotes is highly amusing, though.
BTW, if you run the file through native2ascii -reverse Foo.java Foo.java.native
, you get the real code being compiled.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@DRXor When people with no programming knowledge posted asking for someone to modify a plugin, I'd usually give it to them like that, just to see if they knew what was what.