1
/**
2
* Big5字與Unicode的互換
3
* 轉換后的正常字型
4
*/
5
6
import java.io.*;
7
8
public class MyUtil{
9
public static String big5ToUnicode(String s){
10
try{
11
return new String(s.getBytes("ISO8859_1"), "Big5");
12
}
13
catch (UnsupportedEncodingException uee){
14
return s;
15
}
16
}
17
18
public static String UnicodeTobig5(String s){
19
try{
20
return new String(s.getBytes("Big5"), "ISO8859_1");
21
}
22
catch (UnsupportedEncodingException uee){
23
return s;
24
}
25
}
26
27
public static String toHexString(String s){
28
String str="";
29
for (int i=0; i<s.length(); i++){
30
int ch=(int)s.charAt(i);
31
String s4="0000"+Integer.toHexString(ch);
32
str=str+s4.substring(s4.length()-4)+" ";
33
}
34
return str;
35
}
36
}

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
