Przeglądaj źródła

'修改写入车辆信息时的内容,卡签信息查询新增字符编码判断'

master
wq 2 lat temu
rodzic
commit
de3cb79a93

+ 12
- 1
app/src/main/java/com/huntersun/vkyes/etcopencard/project/copapply/OBURequest.java Wyświetl plik

@@ -151,8 +151,19 @@ public class OBURequest implements HandlerAction {

encryptData.append(Utils.AsciToHexString(item.getVehiclePlate(), 24)); //车牌号
encryptData.append(Utils.IntegerToHexString(Integer.valueOf(item.getVehiclePlateColor()), 4)); //车牌颜色
encryptData.append(Utils.IntegerToHexString(1, 2)); //类型
int vehicleType = 1;
try {
vehicleType = Integer.parseInt(item.getType());
} catch (Exception e) {
vehicleType = 1;
}
encryptData.append(Utils.IntegerToHexString(vehicleType, 2)); //类型(收费车类型)
int customeType = 1; //用户类型
try {
customeType = Integer.parseInt(item.getUserType()); //用户类型
} catch (Exception e) {
customeType = 1;
}
encryptData.append(Utils.IntegerToHexString(customeType, 2));
//获取车辆尺寸
String[] lwh = item.getVehicleDimensions().split(",");

+ 16
- 1
app/src/main/java/com/huntersun/vkyes/etcopencard/project/ui/activity/mail/InfoTabActivity.java Wyświetl plik

@@ -26,6 +26,7 @@ import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean;
import com.huntersun.vkyes.etcopencard.src.app.AppActivity;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -104,7 +105,21 @@ public class InfoTabActivity extends AppActivity {
}
});

}

public static String guessEncoding(byte[] bytes) {
String[] encodings = {"UTF-8", "GBK", "ISO-8859-1", "GB2312", "UTF-16BE", "UTF-16LE", "UTF-32BE", "UTF-32LE"};
for (String encoding : encodings) {
try {
String str = new String(bytes, Charset.forName(encoding));
byte[] bytes2 = str.getBytes(Charset.forName(encoding));
if (bytes.length == bytes2.length) {
return encoding;
}
} catch (Exception e) {
}
}
return null;
}

public static ResultBean.BizContent DecVehInfo(String data) {
@@ -182,7 +197,7 @@ public class InfoTabActivity extends AppActivity {
}
byte[] asd = UtilTool.hexStringToByteArray(data);
try {
str = new String(asd, "GBK");
str = new String(asd, guessEncoding(asd));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

Ładowanie…
Anuluj
Zapisz