create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / utils / L10NGenerator.java
1 package net.sf.openrocket.utils;
2
3 import java.text.Normalizer;
4
5 import net.sf.openrocket.util.Chars;
6
7 /**
8  * This class is used to generate the map used in L10N class
9  * due to the fact that Android does not support java.text.Normalizer.
10  */
11 public class L10NGenerator {
12         
13         public static void main(String[] args) throws Exception {
14                 
15                 // Latin chars
16                 for (char ch = 128; ch < 0x250; ch++) {
17                         output(ch);
18                 }
19                 // Superscript numbers
20                 for (char ch = 0x2070; ch <= 0x2079; ch++) {
21                         output(ch);
22                 }
23                 // Subscript numbers
24                 for (char ch = 0x2080; ch <= 0x2089; ch++) {
25                         output(ch);
26                 }
27                 output(Chars.FRACTION);
28                 print(Chars.ZWSP, " ");
29                 print(Chars.NBSP, " ");
30         }
31         
32         private static void output(char ch) {
33                 String text = "" + ch;
34                 StringBuilder sb = new StringBuilder(text.length());
35                 //                      s = normalize(s);
36                 text = Normalizer.normalize(text, Normalizer.Form.NFKD);
37                 
38                 for (char c : text.toCharArray()) {
39                         if (c < 128) {
40                                 sb.append(c);
41                         } else if (c == Chars.FRACTION) {
42                                 sb.append('/');
43                         }
44                 }
45                 
46                 text = sb.toString().trim();
47                 
48                 if (text.length() > 0) {
49                         print(ch, text);
50                 }
51         }
52         
53         private static void print(char ch, String text) {
54                 System.out.printf("m.put('\\u%04x', \"%s\");\n", (int) ch, text);
55         }
56 }