没有合适的资源?快使用搜索试试~ 我知道了~
中文转utf8 16
4星 · 超过85%的资源 需积分: 32 52 下载量 99 浏览量
2011-11-16
16:16:24
上传
评论
收藏 3KB TXT 举报
温馨提示
试读
3页
16进制转化方式,中文utf8转换 ....
资源推荐
资源详情
资源评论
package com.lqs;
import java.io.File;
import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException;
public class utf8 {
public static void main(String[] args) {
String str = "This is a test for *ÖÐÍø!@#$¡££¬£¿";
try {
File f = new File("D:/test.txt");
FileOutputStream fio = new FileOutputStream(f);
String s = gbToUtf8(str);
fio.write(s.getBytes("UTF-8"));
fio.close(); }
catch (Exception e) {
e.printStackTrace();
}
}
public static String gbToUtf8(String str) throws UnsupportedEncodingException {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
String s = str.substring(i, i + 1);
if (s.charAt(0) > 0x80) {
byte[] bytes = s.getBytes("Unicode");
String binaryStr = "";
for (int j = 2; j < bytes.length; j += 2) {
// the first byte
import java.io.File;
import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException;
public class utf8 {
public static void main(String[] args) {
String str = "This is a test for *ÖÐÍø!@#$¡££¬£¿";
try {
File f = new File("D:/test.txt");
FileOutputStream fio = new FileOutputStream(f);
String s = gbToUtf8(str);
fio.write(s.getBytes("UTF-8"));
fio.close(); }
catch (Exception e) {
e.printStackTrace();
}
}
public static String gbToUtf8(String str) throws UnsupportedEncodingException {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
String s = str.substring(i, i + 1);
if (s.charAt(0) > 0x80) {
byte[] bytes = s.getBytes("Unicode");
String binaryStr = "";
for (int j = 2; j < bytes.length; j += 2) {
// the first byte
资源评论
- shujieqiu2013-02-18非常好用的小软件,能够对文本进行编码转换,特别是UTF16
- reder19882013-05-29不好用,没有起到作用
- heisetaiyang2013-03-11简单,能用
- gongweijun0072013-08-06很实用 对我帮助很大
- 想娜娜的虫2013-04-11不是很好用 白花了
relax12224
- 粉丝: 0
- 资源: 30
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功