Skip to content

Instantly share code, notes, and snippets.

@Dinnerbone
Last active Jan 1, 2016
Embed
What would you like to do?
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);
}
}
@Magvaag

This comment has been minimized.

Copy link

@Magvaag Magvaag commented Dec 23, 2013

?

@AndreasDahl

This comment has been minimized.

Copy link

@AndreasDahl AndreasDahl commented Dec 23, 2013

Division by zero? EXPLAIN YOURSELF!

@samullen

This comment has been minimized.

Copy link

@samullen samullen commented Dec 23, 2013

LOL. I bet Notch could divide by zero.

@proimage

This comment has been minimized.

Copy link

@proimage proimage commented Dec 23, 2013

This may help the confused: http://rishida.net/tools/conversion/

@pdelvo

This comment has been minimized.

Copy link

@pdelvo pdelvo commented Dec 23, 2013

Its funny that the compiler is not smart enough to detect this at compilation

@hanetzer

This comment has been minimized.

Copy link

@hanetzer hanetzer commented Dec 23, 2013

mind == blown

@stertingen

This comment has been minimized.

Copy link

@stertingen stertingen commented Dec 23, 2013

Well, (okay, I have read Twitter) Java has to improve this...

@mcy

This comment has been minimized.

Copy link

@mcy mcy commented Dec 23, 2013

By this logic this https://gist.github.com/drXor/8100658 compiles.

@jglrxavpok

This comment has been minimized.

Copy link

@jglrxavpok jglrxavpok commented Dec 23, 2013

Division by 0 x)
Now I just want to mess up with the compiler :)

@ictrobot

This comment has been minimized.

Copy link

@ictrobot ictrobot commented Dec 23, 2013

:D

@sysr-q

This comment has been minimized.

Copy link

@sysr-q sysr-q commented Dec 23, 2013

@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.

@hakanai

This comment has been minimized.

Copy link

@hakanai hakanai commented Dec 24, 2013

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