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 ...
随机推荐
- Cisco IOS Debug Command Reference Command E through H
debug eap through debug he-module subslot periodic debug eap : to display information about Extensib ...
- SharePoint表单和工作流 - Nintex篇(一)
博客地址 http://blog.csdn.net/foxdave 本篇开始我将带大家去认识一个第三方的表单工作流工具--Nintex. 本篇将对该工具做一些简单的介绍. Nintex公司成立于200 ...
- HTML--3css样式表
CSS(Cascading Style Sheet,叠层样式表),作用是美化HTML网页. /*注释区域*/ 此为注释语法 一.样式表 (一)样式表的分类 1.内联样式表 和HTML联合显示,控 ...
- 【转】FFMPEG 库移植到 VC 需要的步骤
原文:http://blog.csdn.net/leixiaohua1020/article/details/12747899 在VC下使用FFMPEG编译好的库,不仅仅是把.h,.lib,.dll拷 ...
- 产生冠军 map 的 应用 .
开始 比赛 , 每一次的 比赛 都会有人失败 , 如果产生英雄的话 , 那就是产生 唯一一个 没有被打败的人 , 就是英雄, . #include<stdio.h> #includ ...
- Unity3D ShaderLab 透明裁剪着色器
Unity3D ShaderLab 透明裁剪着色器 上一篇,我们介绍了使用Alpha实现透明的手法,其实Unity为我们的#pragma提供了另一种参数,是我们能做出更高效 简单的透明效果,也就是裁剪 ...
- Linux性能监控
转自:http://blog.csdn.net/chosen0ne/article/details/8200737 linux性能监控,就是要监控系统的各个子系统是否正常.linux主要的子系统包括: ...
- CentOS 7.0 安装go 1.3.1
1.下载go安装包 golang中国上下载 2. 解压 tar -zxf go1.3.1.linux-amd64.tar.gz -C /usr/local/ 3. 修改 etc/profile 文件在 ...
- timeZoneGetter
function timeZoneGetter(date) { // getTimezoneOffset 返回格林威治时间和本地时间之间的时差,以分钟为单位 var zone = -1 * date. ...
- Think Python - Chapter 15 - Classes and objects
15.1 User-defined typesWe have used many of Python’s built-in types; now we are going to define a ne ...