Parcourir la source

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

master
wq il y a 2 ans
Parent
révision
de3cb79a93

+ 12
- 1
app/src/main/java/com/huntersun/vkyes/etcopencard/project/copapply/OBURequest.java Voir le fichier



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

+ 16
- 1
app/src/main/java/com/huntersun/vkyes/etcopencard/project/ui/activity/mail/InfoTabActivity.java Voir le fichier

import com.huntersun.vkyes.etcopencard.src.app.AppActivity; import com.huntersun.vkyes.etcopencard.src.app.AppActivity;


import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
} }
}); });


}


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) { public static ResultBean.BizContent DecVehInfo(String data) {
} }
byte[] asd = UtilTool.hexStringToByteArray(data); byte[] asd = UtilTool.hexStringToByteArray(data);
try { try {
str = new String(asd, "GBK");
str = new String(asd, guessEncoding(asd));
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
} }

Chargement…
Annuler
Enregistrer