RT,就是利用BIG5与GB2312码的对照表,代码本身很容易,只是找对照表花了我很长时间.
java 代码
- import
java.io.*;
-
-
-
-
-
- public
class
Big2Gb{
-
private
static
final
String tabFile =
"bg-gb.tab"
;
-
private
static
byte
[] data;
-
static
{
-
try
{
- FileInputStream fis =
new
FileInputStream(tabFile);
-
int
len =fis.available();
- data =
new
byte
[len];
- fis.read(data);
- fis.close();
- }
catch
(Exception ex){
- ex.printStackTrace();
- System.exit(
1
);
- }
- }
-
-
-
-
-
private
static
int
indexOf(
int
big){
-
int
high =(big>>>
8
)&
0xff
;
-
int
low =big&
0xff
;
-
- high -=
0xa1
;
-
if
(low<=
0x7e
) low -=
0x40
;
-
else
low -= (
0xa1
-
0x7e
-
1
) +
0x40
;
-
-
return
2
*(high*
157
+low);
- }
-
-
-
-
-
-
-
public
static
byte
[] translateBig5ToGb(
byte
[] bs){
-
int
index =
0
;
-
while
(index<bs.length){
-
int
high =bs[index]&
0xff
;
-
if
(high>=
0xa1
&&high<=
0xfe
){
- index ++;
-
if
(index>=bs.length)
break
;
-
int
low =bs[index]&
0xff
;
-
if
(low<
0x40
||low>
0xfe
)
continue
;
-
if
(low>
0x7e
&&low<
0xa1
)
continue
;
-
int
offset =indexOf((high<<
8
)|low);
- bs[index-
1
] =data[offset];
- bs[index ] =data[offset+
1
];
- index++;
- }
-
else
index++;
- }
-
return
bs;
- }
-
-
public
static
String translateBig5ToGb(String big){
- String result =
null
;
-
try
{
-
byte
[] bs =big.getBytes(
"big5"
);
- bs =translateBig5ToGb(bs);
- result =
new
String(bs,
"gb2312"
);
- }
catch
(Exception e){
- }
-
return
result;
- }
-
- }
分享到:
相关推荐
VB中的简体中文(GB2312) -繁体中文(Big5)转换程序。 说明:按下 Mouse 的右键,选择『编码』里的『GB2312』查看输出结果。
简体繁体转换利器gb2312,big5,utf-8各种编码批量互转,非常强大的一个工具,一个台湾朋友介绍我使用的.一般人我不告诉他.
GB/BIG5/UTF-8 文件编码批量转换工具 功能:将 GB/BIG5/UTF-8 编码的文件相互转换,主要应用于网站编码方式的整体转换上。
1、可以支持常见编码格式如UTF-8、UTF-7、Unicod、ASCII、GB2312、Big5之间的转换。 2、支持选取文件夹批量、文件多选、翦贴板中复制三种文件批量选取方式,能实现指量转换。 3、支持文件过滤,采用openFileDialog...
解决整站编码转换难题,utf-8,gb2312,big随意转换
最新版的文件编码转换工具 可以在UTF-8,GB,BIG5之间进行字符转换
GB/BIG5/UTF-8 文件编码批量转换程序 博文链接:https://knight.iteye.com/blog/92688
vc在GB码和Big5码间转换字符编码.zip
支持在PHP中将编码转换为指定的编码方式 gb2big5 big52gb utf82u u2utf8 gb2utf8 utf82gb
是一款单一文件与批量转换编码工具将 GB、BIG5、UTF-8 文件相互转换,方便的批量处理能力,主要用于网站文件编码方式的整体转换上。 豆葵 www.doukui.cn 是立足垂直搜索主要提供技术性的网站进行搜索.
big5码转换器,很好用的,还算可以big5码转换器,很好用的,还算可以
自己编写的Big5编码台湾繁体字体和GBK编码简体字体之间相互转换示例代码,亲测可以编译运行。
CC++ 字符编码的转换(ut8、gb2312,gbk,big5)
VB源码,查表方式进行简繁转换,GB码与BIG5码的相互转换
将 GB、BIG5、UTF-8 文件相互转换,方便的批量处理能力,主要用于网站文件编码方式的整体转换上。