fork(1) download
  1. importPackage(java.io);
  2. importPackage(java.lang);
  3.  
  4. // \x9 throws an error when using JavaScript (SMonkey 24.2.0).
  5. print("\\x only works with two hex digits: TAB\x9TAB\x090TAB");
  6. print("\\x is ISO-8859-1: 0x80 = \x80, 0x81 = \x81, 0x90 = \x90, 0x9A = \x9A, 0x9F = \x9F");
  7. print("\\x is _not_ creating UTF-8: \xE0\xBC\x82"); // UTF-8 bytes for U+0F02
  8. print("");
  9.  
  10. print("BMP Code Point / UTF-16 via \\u: \u0F02");
  11. print("UTF-16 Surrogate Pair via \\u: \uD83D\uDC7E"); // U+1F47E
  12. print("");
  13.  
  14. // \u{} throws an error when using JavaScript (SMonkey 24.2.0).
  15. print("\\u{} is noted as being \"experimental, should not be used in production code\":");
  16. print("Code Point / UTF-32 via \\u{}: \u{0F02}"); // NO EFFECT (YET!!!)
  17. print("Code Point / UTF-32 via \\u{}: \u{1F47E}"); // NO EFFECT (YET!!!)
  18. print("-------------------------------");
  19.  
  20. print("UTF-16 via String.fromCharCode(decimal): " + String.fromCharCode(3842));
  21. print("UTF-16 via String.fromCharCode(hex): " + String.fromCharCode(0x0F02));
  22. print("");
  23.  
  24. print("UTF-16 Surrogate Pair via String.fromCharCode(decimal): " + String.fromCharCode(55357, 56446));
  25. print("UTF-16 Surrogate Pair via String.fromCharCode(hex): " + String.fromCharCode(0xD83D, 0xDC7E));
  26. print("");
  27.  
  28. print("Multiple UTF-16 via String.fromCharCode(decimal): " + String.fromCharCode(3842, 32, 55357, 56446));
  29. print("Multiple UTF-16 via String.fromCharCode(hex): " + String.fromCharCode(0x0F02, 0x20, 0xD83D, 0xDC7E));
  30. print("-------------------------------");
  31.  
  32. // Like \x, the octal escape sequence uses the ISO-8859-1 character set
  33. print("Octal notation is \\888 where '888' = 1 - 3 octal digits (values 0 - 7; range 0 - 377):")
  34. print("\\11 and \\011: tab\11tabby\011tab");
  35. print("\\7, \\07, and \\007: bell\7bell\07bell\007bell");
  36. print("\\176 = \176 ; \\177 = \177 ; \\200 = \200 ; \\237 = \237");
  37. print("\\242 = \242 ; \\377 = \377 ; \\504 = \504");
  38. print("-------------------------------");
  39.  
  40. // String.fromCodePoint() raises an error in both (rhino 1.7.7) and (SMonkey 24.2.0).
  41. //print("Code Point / UTF-32 via String.fromCodePoint(decimal): " + String.fromCodePoint(3842));
  42. //print("Code Point / UTF-32 via String.fromCodePoint(hex): " + String.fromCodePoint(0x0F02));
  43.  
Success #stdin #stdout 0.26s 2181632KB
stdin
Standard input is empty
stdout
\x only works with two hex digits: TABx9TAB	0TAB
\x is ISO-8859-1: 0x80 = €, 0x81 = , 0x90 = , 0x9A = š, 0x9F = Ÿ
\x is _not_ creating UTF-8: ༂

BMP Code Point / UTF-16 via \u: ༂
UTF-16 Surrogate Pair via \u: 👾

\u{} is noted as being "experimental, should not be used in production code":
Code Point / UTF-32 via \u{}: u{0F02}
Code Point / UTF-32 via \u{}: u{1F47E}
-------------------------------
UTF-16 via String.fromCharCode(decimal): ༂
UTF-16 via String.fromCharCode(hex): ༂

UTF-16 Surrogate Pair via String.fromCharCode(decimal): 👾
UTF-16 Surrogate Pair via String.fromCharCode(hex): 👾

Multiple UTF-16 via String.fromCharCode(decimal): ༂ 👾
Multiple UTF-16 via String.fromCharCode(hex): ༂ 👾
-------------------------------
Octal notation is \888 where '888' = 1 - 3 octal digits (values 0 - 7; range 0 - 377):
\11 and \011: tab	tabby	tab
\7, \07, and \007: bellbellbellbell
\176 = ~ ; \177 =  ; \200 = € ; \237 = Ÿ
\242 = ¢ ; \377 = ÿ ; \504 = (4
-------------------------------