summaryrefslogtreecommitdiffstats
path: root/base/util/src/netscape/security/util/PrintableCharset.java
blob: a9cf15c04231996444165d534aeb39ee76e31b77 (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
41
42
43
44
45
46
package netscape.security.util;

import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;

public class PrintableCharset extends Charset {

    public PrintableCharset() {
        super("ASN.1-Printable", null);
    }

    public static boolean isPrintableChar(char c) {
        if ((c < 'A' || c > 'Z') &&
                (c < 'a' || c > 'z') &&
                (c < '0' || c > '9') &&
                (c != ' ') &&
                (c != '\'') &&
                (c != '(') &&
                (c != ')') &&
                (c != '+') &&
                (c != ',') &&
                (c != '-') &&
                (c != '.') &&
                (c != '/') &&
                (c != ':') &&
                (c != '=') &&
                (c != '?')) {
            return false;
        } else {
            return true;
        }
    }

    public boolean contains(Charset cs) {
        return false;
    }

    public CharsetDecoder newDecoder() {
        return new PrintableCharsetDecoder(this);
    }

    public CharsetEncoder newEncoder() {
        return new PrintableCharsetEncoder(this);
    }
}