return serverip.toString();
}
+ public static String utf8ToUnicode(String inStr) {
+ char[] myBuffer = inStr.toCharArray();
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < inStr.length(); i++) {
+ Character.UnicodeBlock ub = Character.UnicodeBlock.of(myBuffer[i]);
+ if (ub == Character.UnicodeBlock.BASIC_LATIN) {
+ //英文及数字等
+ sb.append(myBuffer[i]);
+ } else if (ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
+ //全角半角字符
+ int j = (int) myBuffer[i] - 65248;
+ sb.append((char) j);
+ } else {
+ //汉字
+ short s = (short) myBuffer[i];
+ String hexS = Integer.toHexString(s);
+ String unicode = "\\u" + hexS;
+ sb.append(unicode.toLowerCase());
+ }
+ }
+ return sb.toString();
+ }
+
/**
* 此函数专门给L02 协议使用 ,解析名字用
*
outBuffer.append(aChar);
}
return outBuffer.toString();
-
-
}
public static String getSystemProperties(String prop) {
e.printStackTrace();
ICLogger.e(e.getMessage(), e);
}
- ICLogger.i("getSystemProperties str = "+str);
+ ICLogger.i("getSystemProperties str = " + str);
return str;
}
}
}
- public static boolean parseToVoicePacketSent(VoiceContent voiceContent,int packetSize) {
+ public static boolean parseToVoicePacketSent(VoiceContent voiceContent, int packetSize) {
long filesize;
File voicefile = new File(voiceContent.content);
fis.close();
voicePacket.getInstanceSent().setCurrentIndexToSent(0);
voicePacket.getInstanceSent().setPacketTime(TimeUtil.getSystemTime3());
- if( voiceContent.filetype==1) //* 1 语音—— 1.监听语音 * 2.SOS语音 * 3.扩展
+ if (voiceContent.filetype == 1) //* 1 语音—— 1.监听语音 * 2.SOS语音 * 3.扩展
{
- int duration=Util.getDuration(voiceContent.content);
- voicePacket.getInstanceSent().setDurationHex(String.format("%04X",duration));
- }else{
+ int duration = Util.getDuration(voiceContent.content);
+ voicePacket.getInstanceSent().setDurationHex(String.format("%04X", duration));
+ } else {
voicePacket.getInstanceSent().setDurationHex("0000");
}
return true;
}
return ret;
}
+
public static String UrlGB2312ToUTF8(String url) {
String ret = "";
String src = url;
ICLogger.d("value ==> " + value);
//如果是-1,那么是空消息
//如果是其他数字,通过id去查询即可
- if (!"none".equals(value)) {
+ if (!"none".equals(value) && !"success".equals(value)) {
//先查询出内容,再组装数据
ContentResolver resolver = mRuntime.getContextProxy().getResolver();
Cursor query = resolver.query(Uri.parse(ShootTextProvider.SHOOT_TEXT),
.append(CMDSPLIT).append(lowPressure)
.append(CMDSPLIT).append(highPressure)
.append(CMDSPLIT).append(batteryLev)
- .append(CMDSPLIT).append(msg)
+ .append(CMDSPLIT).append(Util.utf8ToUnicode(msg))//utf8转unicode
.append(CMDSPLIT).append(mRuntime.getS123GpsData())
.append(CMDSPLIT).append("wgs84")//原始经纬度
.append(CMDSPLIT).append(mRuntime.getSignalStrength())