Java中将16进制字符串转换成汉字
技术交流群:233513714
/**
* 将16进制字符串转换成汉字
* @param str
* @return
*/
public static String deUnicode(String str) {
byte[] bytes = new byte[str.length() / 2];
byte tempByte = 0;
byte tempHigh = 0;
byte tempLow = 0;
for (int i = 0, j = 0; i < str.length(); i += 2, j++) {
tempByte = (byte) (((int) str.charAt(i)) & 0xff);
if (tempByte >= 48 && tempByte <= 57) {
tempHigh = (byte) ((tempByte - 48) << 4);
} else if (tempByte >= 97 && tempByte <= 101) {
tempHigh = (byte) ((tempByte - 97 + 10) << 4);
}
tempByte = (byte) (((int) str.charAt(i + 1)) & 0xff);
if (tempByte >= 48 && tempByte <= 57) {
tempLow = (byte) (tempByte - 48);
} else if (tempByte >= 97 && tempByte <= 101) {
tempLow = (byte) (tempByte - 97 + 10);
}
bytes[j] = (byte) (tempHigh | tempLow);
}
String result = null;
try {
result = new String(bytes, "GBK");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
Java中将16进制字符串转换成汉字的更多相关文章
- iOS 16进制字符串转换成int十进制
NSRange rangeErr; rangeErr.location = 6; rangeErr.length = 2; NSString *strings = [value substringWi ...
- C++实现16进制字符串转换成int整形值
开发中经常需要把16进制字符串转换成整形,写了个个代码供大家参考下: #include <stdio.h> #include <string.h> //字符转换成整形 int ...
- 字节流、字符串、16进制字符串转换__Java(转)
/** * @Package: * @ClassName:TypeConversion * @Description:字节流.字符串.16进制字符串转换 * @author:xk * @date:Ja ...
- 字节流、字符串、16进制字符串转换__java
package com.dvn.li.main; /** * @Package: * @ClassName:TypeConversion * @Description:字节流.字符串.16进制字符串转 ...
- java中 16进制字符串 与普通字符串 与 byte数组 之间的转化
方法依赖commons-codec包 maven的引入方式如下 <dependency> <groupId>commons-codec</groupId> < ...
- 字节数组(byte[])与16进制字符串转换
/// <summary> /// 转换扩展类 /// </summary> public static class ConvertExtend { /// <summa ...
- 16进制色值转换成RGB
#51147f 转换成RGB ,5*16+1 ,1*16+4,7*16+15 #A9A9A9 转换成RGB ,A*16+9 ,A*16+9,A*16+9
- 将16进制颜色转换成UIColor-ios
-(UIColor *) hexStringToColor: (NSString *) stringToConvert { NSString *cString = [[stringToConvert ...
- C#字符串和16进制字符串之间的转换
将字符串编码成 16进制 字符串表示: using System;using System.Collections.Generic;using System.Linq;using System.Tex ...
随机推荐
- Jquery Table 操作
获取行号 var rowIndex = $("#TableId").find("tr").index($("#RowId")[0]); va ...
- ios上架
1.登录developer.apple.com 2.点击member center后 进下图 3.点击certificates Identifiers进下图 4.点击Certificates进下图,首 ...
- hive 中 union all
hive 中的union all是不能在sql语句的第一层使用的,否则会报 Top level UNION is not supported currently 错误: 例如如下的方式: select ...
- 查看某个html标签有哪些属性和事件
<html><head><script> //查看input标签有哪些属性和事件 function a() { var str = new String(" ...
- GSM BTS Hacking: 利用BladeRF和开源BTS 5搭建基站
引文 如果你已经购买了Nuand(官方)BladeRF x40,那么就可以在上面运行OpenBTS并可以输入一些指令来完成一些任务.一般来说HackRF,是一款覆盖频率最宽的SDR板卡.它几乎所有的信 ...
- BZOJ 4027 兔子与樱花
原来想的是给所有点排序....但是要修改啊...然后发现对于儿子排序就可以了. #include<iostream> #include<cstdio> #include< ...
- IndexOf() LastIndexOf() Contains() StartsWith() EndsWith()方法比较
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...
- Codeforces Round #365 (Div. 2)-D Mishka and Interesting sum(树状数组)
题目链接:http://codeforces.com/contest/703/problem/D 思路:看了神犇的代码写的... 偶数个相同的数异或结果为0,所以区间ans[l , r]=区间[l , ...
- asp.net ToString()格式汇总
C 货币 2.5.ToString("C") ¥2.50 D 十进制数 25.ToString("D5") 00025 E 科学型 25000.ToString ...
- ios开发环境 分支语句 、 循环结构(for) 、 循环结构
1 完成命令解析程序 1.1 问题 有命令解析程序,该程序提供三个功能选项供用户选择,用户选择某功能后,程序在界面上输出用户所选择的功能名称.程序的交互效果如图-1所示: 图-1 由上图可以看出,程序 ...