Skip to content

Commit f569caa

Browse files
committed
fixed charset issue for issue 1
1 parent 3a5ad20 commit f569caa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/qiniu/ip17mon/Locator.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
import java.io.InputStream;
77
import java.net.HttpURLConnection;
88
import java.net.URL;
9+
import java.nio.charset.Charset;
910
import java.util.InputMismatchException;
1011

1112
public final class Locator implements ILocator {
12-
public static final String VERSION = "0.0.2";
13+
public static final String VERSION = "0.1";
14+
private static final Charset Utf8 = Charset.forName("UTF-8");
1315
private final byte[] ipData;
1416
private final int textOffset;
1517
private final int[] index;
@@ -82,8 +84,8 @@ static byte[] textToNumericFormatV4(String str) {
8284
}
8385

8486
static LocationInfo buildInfo(byte[] bytes, int offset, int len) {
85-
String str = new String(bytes, offset, len);
86-
String[] ss = str.split("\t");
87+
String str = new String(bytes, offset, len, Utf8);
88+
String[] ss = str.split("\t", -1);
8789
if (ss.length == 4) {
8890
return new LocationInfo(ss[0], ss[1], ss[2], "");
8991
} else if (ss.length == 5) {

0 commit comments

Comments
 (0)