summaryrefslogtreecommitdiff
path: root/src/thenewpoketext/UnicodeParser.java
blob: 5a209b0bd3cc6fdd891e5ff050ca57074abda4a3 (plain)
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
package thenewpoketext;

/*----------------------------------------------------------------------------*/
/*--  UnicodeParser.java - maintains the poke<->unicode text table          --*/
/*--  Code loosely derived from "thenewpoketext", copyright (C) loadingNOW  --*/
/*----------------------------------------------------------------------------*/

import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

import com.pkrandom.FileFunctions;

public class UnicodeParser {

    public static String[] tb = new String[65536];
    public static Map<String, Integer> d = new HashMap<>();

    static {
        try {
            Scanner sc = new Scanner(FileFunctions.openConfig("Generation4.tbl"), "UTF-8");
            while (sc.hasNextLine()) {
                String q = sc.nextLine();
                if (!q.trim().isEmpty()) {
                    String[] r = q.split("=", 2);
                    if (r[1].endsWith("\r\n")) {
                        r[1] = r[1].substring(0, r[1].length() - 2);
                    }
                    tb[Integer.parseInt(r[0], 16)] = r[1];
                    d.put(r[1], Integer.parseInt(r[0], 16));
                }
            }
            sc.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

}