-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy path_codecs_jp.java
More file actions
32 lines (28 loc) · 938 Bytes
/
Copy path_codecs_jp.java
File metadata and controls
32 lines (28 loc) · 938 Bytes
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
package org.python.modules.cjkcodecs;
import org.python.core.Py;
import org.python.core.PyObject;
import org.python.expose.ExposedFunction;
import org.python.expose.ExposedModule;
import java.nio.charset.Charset;
/**
* Created by isaiah on 8/15/16.
*/
@ExposedModule
public class _codecs_jp {
private static Charset EUC_JP = Charset.forName("euc_jp");
private static Charset SHIFT_JIS = Charset.forName("shift_jis");
private static Charset MS932 = Charset.forName("MS932");
@ExposedFunction
public static PyObject getcodec(String name) {
switch(name) {
case "euc_jp":
return new PyMultibyteCodec(EUC_JP);
case "shift_jis":
return new PyMultibyteCodec(SHIFT_JIS);
case "ms932":
return new PyMultibyteCodec(MS932);
default:
throw Py.LookupError("no such codec is supported");
}
}
}