Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
76 lines (70 loc) · 2.97 KB

File metadata and controls

76 lines (70 loc) · 2.97 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Helper to test Java case conversion (useful for comparison).
*/
import java.util.Locale;
import java.util.Properties;
public class CaseConversion {
public static final String dump(String x) throws Exception {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < x.length(); i++) {
if (i != 0) { sb.append(" "); }
sb.append(String.format("U+%04x", (int) x.charAt(i)));
}
return sb.toString();
}
public static final char getCharFromHex(String x) throws Exception {
return Character.toChars(Integer.valueOf(x, 16))[0];
}
/* Parse string as is, except recognize backslash followed by 'u'
* (4 hex digit escape), 'x' (2 hex digit escape) and another backslash
* (backslash escape). Note that when using this from a Unix shell,
* backslashes need to be escaped for the shell too.
*/
public static final String parseEscaped(String x) throws Exception {
StringBuffer sb = new StringBuffer();
for (int i = 0;;) {
if (i == x.length()) {
break;
} else if (i > x.length()) {
throw new Exception("invalid input");
}
char c = x.charAt(i);
if (c != '\\') {
sb.append(c);
i++;
} else {
c = x.charAt(i + 1);
if (c == 'x') {
sb.append(getCharFromHex(x.substring(i + 2, i + 4)));
i += 4;
} else if (c == 'u') {
sb.append(getCharFromHex(x.substring(i + 2, i + 6)));
i += 6;
} else if (c == '\\') {
sb.append('\\');
i += 2;
} else {
throw new Exception("invalid input");
}
}
}
return sb.toString();
}
public static final void main(String args[]) throws Exception {
Properties sysProps = System.getProperties();
Locale locale = new Locale(args[0]);
String inputString = parseEscaped(args[1]);
String uc = inputString.toUpperCase(locale);
String lc = inputString.toLowerCase(locale);
System.out.println("java.version: " + sysProps.getProperty("java.version"));
System.out.println("java.vendor: " + sysProps.getProperty("java.vendor"));
System.out.println("java.vendor.url: " + sysProps.getProperty("java.vendor.url"));
System.out.println("java.vm.version: " + sysProps.getProperty("java.vm.version"));
System.out.println("java.vm.vendor: " + sysProps.getProperty("java.vm.vendor"));
System.out.println("java.vm.name: " + sysProps.getProperty("java.vm.name"));
System.out.println("Locale: " + locale);
System.out.println("Input: " + dump(inputString));
System.out.println("toUpperCase: " + dump(uc));
System.out.println("toLowerCase: " + dump(lc));
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.