Skip to content

Commit fcb970c

Browse files
committed
Unicode To Chinese
Unicode To Chinese
1 parent c029964 commit fcb970c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4448
-0
lines changed

U2C/GUI.java

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package U2C;
2+
3+
import java.awt.EventQueue;
4+
import java.awt.FlowLayout;
5+
import java.awt.Font;
6+
import java.awt.event.MouseAdapter;
7+
import java.awt.event.MouseEvent;
8+
import java.net.URI;
9+
import javax.swing.JFrame;
10+
import javax.swing.JPanel;
11+
import java.awt.BorderLayout;
12+
import java.awt.Color;
13+
import java.awt.Desktop;
14+
15+
import javax.swing.JCheckBox;
16+
import javax.swing.JLabel;
17+
import javax.swing.border.LineBorder;
18+
import java.awt.Label;
19+
import java.awt.GridBagLayout;
20+
import java.awt.GridBagConstraints;
21+
import java.awt.Insets;
22+
23+
public class GUI {
24+
25+
public JFrame frame;
26+
public String ExtenderName = "U2C v0.1 by bit4";
27+
public String github = "https://github.com/bit4woo/U2C";
28+
public JLabel lblNewLabel_1;
29+
public JCheckBox chckbx_proxy;
30+
public JCheckBox chckbx_repeater;
31+
public JCheckBox chckbx_intruder;
32+
private JPanel content_panel;
33+
private JCheckBox chckbx_display;
34+
35+
/**
36+
* Launch the application.
37+
*/
38+
public static void main(String[] args) {
39+
EventQueue.invokeLater(new Runnable() {
40+
public void run() {
41+
try {
42+
GUI window = new GUI();
43+
window.frame.setVisible(true);
44+
} catch (Exception e) {
45+
e.printStackTrace();
46+
}
47+
}
48+
});
49+
}
50+
51+
/**
52+
* Create the application.
53+
*/
54+
public GUI() {
55+
initialize();
56+
}
57+
58+
/**
59+
* Initialize the contents of the frame.
60+
*/
61+
private void initialize() {
62+
frame = new JFrame();
63+
frame.setBounds(100, 100, 450, 300);
64+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
65+
66+
67+
content_panel = new JPanel();
68+
content_panel.setBorder(new LineBorder(new Color(0, 0, 0)));
69+
content_panel.setLayout(new BorderLayout(0, 0));
70+
71+
frame.getContentPane().add(content_panel, BorderLayout.CENTER);
72+
73+
JPanel panel = new JPanel();
74+
content_panel.add(panel, BorderLayout.NORTH);
75+
FlowLayout fl_panel = (FlowLayout) panel.getLayout();
76+
fl_panel.setAlignment(FlowLayout.LEFT);
77+
panel.setBorder(new LineBorder(new Color(0, 0, 0)));
78+
79+
JLabel lblNewLabel = new JLabel("Enable for : ");
80+
panel.add(lblNewLabel);
81+
82+
chckbx_proxy = new JCheckBox("Proxy");
83+
chckbx_proxy.setSelected(true);
84+
panel.add(chckbx_proxy);
85+
86+
chckbx_repeater = new JCheckBox("Repeater");
87+
panel.add(chckbx_repeater);
88+
89+
chckbx_intruder = new JCheckBox("Intruder");
90+
panel.add(chckbx_intruder);
91+
92+
JLabel lblNewLabel_display = new JLabel("|");
93+
panel.add(lblNewLabel_display);
94+
95+
chckbx_display = new JCheckBox("Only Display Converted Body");
96+
panel.add(chckbx_display);
97+
98+
JPanel panel_1 = new JPanel();
99+
content_panel.add(panel_1, BorderLayout.SOUTH);
100+
panel_1.setBorder(new LineBorder(new Color(0, 0, 0)));
101+
FlowLayout flowLayout = (FlowLayout) panel_1.getLayout();
102+
flowLayout.setAlignment(FlowLayout.LEFT);
103+
104+
105+
lblNewLabel_1 = new JLabel(" "+github);
106+
lblNewLabel_1.setFont(new Font("", Font.BOLD, 12));
107+
lblNewLabel_1.addMouseListener(new MouseAdapter() {
108+
@Override
109+
public void mouseClicked(MouseEvent e) {
110+
try {
111+
URI uri = new URI(github);
112+
Desktop desktop = Desktop.getDesktop();
113+
if(Desktop.isDesktopSupported()&&desktop.isSupported(Desktop.Action.BROWSE)){
114+
desktop.browse(uri);
115+
}
116+
} catch (Exception e2) {
117+
// TODO: handle exception
118+
//callbacks.printError(e2.getMessage());
119+
}
120+
121+
}
122+
@Override
123+
public void mouseEntered(MouseEvent e) {
124+
lblNewLabel_1.setForeground(Color.BLUE);
125+
}
126+
@Override
127+
public void mouseExited(MouseEvent e) {
128+
lblNewLabel_1.setForeground(Color.BLACK);
129+
}
130+
});
131+
panel_1.add(lblNewLabel_1);
132+
133+
JPanel panel_2 = new JPanel();
134+
content_panel.add(panel_2, BorderLayout.CENTER);
135+
GridBagLayout gbl_panel_2 = new GridBagLayout();
136+
gbl_panel_2.columnWidths = new int[]{660, 0};
137+
gbl_panel_2.rowHeights = new int[]{23, 23, 15, 0};
138+
gbl_panel_2.columnWeights = new double[]{0.0, Double.MIN_VALUE};
139+
gbl_panel_2.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
140+
panel_2.setLayout(gbl_panel_2);
141+
142+
Label label = new Label("To display chinese correctly, you should do the following config: ");
143+
label.setFont(new Font("Dialog", Font.PLAIN, 14));
144+
GridBagConstraints gbc_label = new GridBagConstraints();
145+
gbc_label.anchor = GridBagConstraints.NORTHWEST;
146+
gbc_label.insets = new Insets(0, 0, 5, 0);
147+
gbc_label.gridx = 0;
148+
gbc_label.gridy = 0;
149+
panel_2.add(label, gbc_label);
150+
Label label1 = new Label("User options-->Display-->HTTP Message Display-->Change font, select a font that support chinese,eg:Microsoft Yahei.");
151+
label1.setFont(new Font("Dialog", Font.PLAIN, 14));
152+
GridBagConstraints gbc_label1 = new GridBagConstraints();
153+
gbc_label1.anchor = GridBagConstraints.NORTHWEST;
154+
gbc_label1.insets = new Insets(0, 0, 5, 0);
155+
gbc_label1.gridx = 0;
156+
gbc_label1.gridy = 1;
157+
panel_2.add(label1, gbc_label1);
158+
159+
JLabel lbllike = new JLabel("if you like this extender, Please give me a star on github. thanks! any issue or suggestion also appreciated!");
160+
lbllike.setFont(new Font("Dialog", Font.PLAIN, 14));
161+
GridBagConstraints gbc_lbllike = new GridBagConstraints();
162+
gbc_lbllike.anchor = GridBagConstraints.NORTHWEST;
163+
gbc_lbllike.gridx = 0;
164+
gbc_lbllike.gridy = 2;
165+
panel_2.add(lbllike, gbc_lbllike);
166+
}
167+
168+
}

U2C/Unicode.java

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package U2C;
2+
3+
/**
4+
* 工具类
5+
*/
6+
public class Unicode {
7+
8+
/**
9+
* unicode解码(unicode编码转中文)
10+
*
11+
* @param theString
12+
* @return
13+
*/
14+
public static String unicodeDecode(String theString) {
15+
char aChar;
16+
int len = theString.length();
17+
StringBuffer outBuffer = new StringBuffer(len);
18+
for (int x = 0; x < len;) {
19+
aChar = theString.charAt(x++);
20+
if (aChar == '\\') {
21+
aChar = theString.charAt(x++);
22+
23+
if (aChar == 'u') {
24+
int value = 0;
25+
for (int i = 0; i < 4; i++) {
26+
aChar = theString.charAt(x++);
27+
switch (aChar) {
28+
case '0':
29+
case '1':
30+
case '2':
31+
case '3':
32+
case '4':
33+
case '5':
34+
case '6':
35+
case '7':
36+
case '8':
37+
case '9':
38+
value = (value << 4) + aChar - '0';
39+
break;
40+
case 'a':
41+
case 'b':
42+
case 'c':
43+
case 'd':
44+
case 'e':
45+
case 'f':
46+
value = (value << 4) + 10 + aChar - 'a';
47+
break;
48+
case 'A':
49+
case 'B':
50+
case 'C':
51+
case 'D':
52+
case 'E':
53+
case 'F':
54+
value = (value << 4) + 10 + aChar - 'A';
55+
break;
56+
default:
57+
throw new IllegalArgumentException(
58+
"Malformed \\uxxxx encoding.");
59+
}
60+
}
61+
outBuffer.append((char) value);
62+
} else {
63+
if (aChar == 't')
64+
aChar = '\t';
65+
else if (aChar == 'r')
66+
aChar = '\r';
67+
else if (aChar == 'n')
68+
aChar = '\n';
69+
else if (aChar == 'f')
70+
aChar = '\f';
71+
outBuffer.append(aChar);
72+
}
73+
} else
74+
outBuffer.append(aChar);
75+
}
76+
return outBuffer.toString();
77+
}
78+
public static void main(String[] args) throws Exception {
79+
//String unicodestring = "\u624b\u673a\u9a8c\u8bc1\u5931\u8d25\uff0c\u8bf7\u91cd\u65b0\u5c1d\u8bd5";
80+
String unicodestring = "{\"code\":404,\"message\":\"\u624b\u673a\u9a8c\u8bc1\u5931\u8d25\uff0c\u8bf7\u91cd\u65b0\u5c1d\u8bd5\"}";
81+
System.out.println(unicodeDecode(unicodestring));
82+
}
83+
}

0 commit comments

Comments
 (0)