5 个解决方案
#1
jdk/bin/native2ascii
看看这个命令对你有帮助否
看看这个命令对你有帮助否
#2
问题得已解决了!谢谢张润福大师,帮我解决了,我的承诺不会改,请到我网站上下一下电子书籍,免费的,超过本,这几天我还要加,基本上全是java的!
#3
接分
#4
-
本来这个贴子在javaworld里也我也发了,因为这是公司交给我一个任务的关键地方,年底搞不好,我过年都不愉快,本想请各位高手帮我解答,我一介贫民,无以图报,只想将自己珍藏的本java,电子书籍给大家共享,目的也是为了开放源码,提供交流学习的平台,所以我将书籍会部上传到我网站了,全是免费的,有几本是bea,sun,公司的内部培训资料,是我个人参加培训时收藏的,我这些作法,没想到,javaworld意以“君子”之心度“小人”之腹,将的说的网站删除,并且还加了很多标记,"don't Don't be lured, please! ","Your advertisement for your website is really pretty smart. "这是我想都没想到的,开源,开源,学习,,我竟还不知道javaworld办站的宗旨是什么,我很痛心,(不要误会,我在这里不是在背地说javaworld坏话,只是发表一下内心的话)我觉得我们IT界就多应该多一个子"张润福大师,学习他的学习精神,学习他的奉献,学习他的无私,我真诚的希望大家,同样的it人,多一点气度,多一点包容,多一点理解,多一点支持,少一点猜疑,少一点抱怨,这样,程序人生,人生程序,也就无悔了。。。
现将将张大师的源码公开如下,旨在让大家少走一些弯路,:
package com.kefa.zhang.string;
/**
* <p>标题:中文字符串比较</p>
* <p>描述: 由于java使用unicode编码作为内吗,因此造成汉字的内码与中国国家汉字
* 内码标准不一致,从而导致了中文字符串得比较和排序相当困难。本类在分析以上
* 问题之后,解决的一级汉字(常用)汉字按照拼音排序的问题</p>
* <p>作者:张润福</p>
*
* */
public class gbkStringCompareTools {
private static String _FromEncode_ = "GBK";
private static String _ToEncode_ = "GBK";
protected gbkStringCompareTools() {
}
public static int compare(String str1,String str2){
int result =0;
String m_s1 = null,m_s2 = null;
try {
m_s1 = new String(str1.getBytes(_FromEncode_),_ToEncode_);
m_s2 = new String(str2.getBytes(_FromEncode_),_ToEncode_);
} catch(Exception e){
return str1.compareTo(str2);
}
result = chineseCompareTo(m_s1,m_s2);
return result;
}
public static int getCharCode(String s){
if (s == null && s.equals(""))
return -1;
byte[] b = s.getBytes();
int value = 0;
for (int i = 0; i < b.length && i <= 2; i++){
value = value*100 + b[i]; //*100左移
}
return value;
}
public static int chineseCompareTo(String s1, String s2) {
int len1 = s1.length();
int len2 = s2.length();
int n = Math.min(len1, len2);
for (int i = 0; i < n; i++) {
int s1_code = getCharCode(s1.charAt(i) + "");
int s2_code = getCharCode(s2.charAt(i) + "");
if (s1_code*s2_code<0)
return Math.min(s1_code,s2_code);
if (s1_code != s2_code)
return s1_code - s2_code;
}
return len1 - len2;
}
public static String getBeginCharacter(String res) {
String a = res;
String result = "";
String current;
for(int i=0;i<a.length();i++){
current = a.substring(i,i+1);
if (gbkStringCompareTools.compare(current,"啊")<0 ) //字母,数字原样返回
result += current;
else if ((gbkStringCompareTools.compare(current, "啊")>=0) && (gbkStringCompareTools.compare(current,"座")) <= 0){
if (gbkStringCompareTools.compare(current,"匝") >= 0)
result += "z";
else if (gbkStringCompareTools.compare(current,"压") >=0)
result += "y";
else if (gbkStringCompareTools.compare(current,"昔") >=0)
result += "x";
else if (gbkStringCompareTools.compare(current,"挖") >=0)
result += "w";
else if (gbkStringCompareTools.compare(current,"塌") >=0)
result += "t";
else if (gbkStringCompareTools.compare(current,"撒") >=0)
result += "s";
else if (gbkStringCompareTools.compare(current,"然") >=0)
result += "r";
else if (gbkStringCompareTools.compare(current,"期") >=0)
result += "q";
else if (gbkStringCompareTools.compare(current,"啪") >=0)
result += "p";
else if (gbkStringCompareTools.compare(current,"哦") >=0)
result += "o";
else if (gbkStringCompareTools.compare(current,"拿") >=0)
result += "n";
else if (gbkStringCompareTools.compare(current,"妈") >=0)
result += "m";
else if (gbkStringCompareTools.compare(current,"垃") >=0)
result += "l";
else if (gbkStringCompareTools.compare(current,"喀") >=0)
result += "k";
else if (gbkStringCompareTools.compare(current,"击") >0)
result += "j";
else if (gbkStringCompareTools.compare(current,"哈") >=0)
result += "h";
else if (gbkStringCompareTools.compare(current,"噶") >=0)
result += "g";
else if (gbkStringCompareTools.compare(current,"发") >=0)
result += "f";
else if (gbkStringCompareTools.compare(current,"蛾") >=0)
result += "e";
else if (gbkStringCompareTools.compare(current,"搭") >=0)
result += "d";
else if (gbkStringCompareTools.compare(current,"擦") >=0)
result += "c";
else if (gbkStringCompareTools.compare(current,"芭") >=0)
result += "b";
else if (gbkStringCompareTools.compare(current,"啊") >=0)
result += "a";
}
}
return result;
}
}
本来这个贴子在javaworld里也我也发了,因为这是公司交给我一个任务的关键地方,年底搞不好,我过年都不愉快,本想请各位高手帮我解答,我一介贫民,无以图报,只想将自己珍藏的本java,电子书籍给大家共享,目的也是为了开放源码,提供交流学习的平台,所以我将书籍会部上传到我网站了,全是免费的,有几本是bea,sun,公司的内部培训资料,是我个人参加培训时收藏的,我这些作法,没想到,javaworld意以“君子”之心度“小人”之腹,将的说的网站删除,并且还加了很多标记,"don't Don't be lured, please! ","Your advertisement for your website is really pretty smart. "这是我想都没想到的,开源,开源,学习,,我竟还不知道javaworld办站的宗旨是什么,我很痛心,(不要误会,我在这里不是在背地说javaworld坏话,只是发表一下内心的话)我觉得我们IT界就多应该多一个子"张润福大师,学习他的学习精神,学习他的奉献,学习他的无私,我真诚的希望大家,同样的it人,多一点气度,多一点包容,多一点理解,多一点支持,少一点猜疑,少一点抱怨,这样,程序人生,人生程序,也就无悔了。。。
现将将张大师的源码公开如下,旨在让大家少走一些弯路,:
package com.kefa.zhang.string;
/**
* <p>标题:中文字符串比较</p>
* <p>描述: 由于java使用unicode编码作为内吗,因此造成汉字的内码与中国国家汉字
* 内码标准不一致,从而导致了中文字符串得比较和排序相当困难。本类在分析以上
* 问题之后,解决的一级汉字(常用)汉字按照拼音排序的问题</p>
* <p>作者:张润福</p>
*
* */
public class gbkStringCompareTools {
private static String _FromEncode_ = "GBK";
private static String _ToEncode_ = "GBK";
protected gbkStringCompareTools() {
}
public static int compare(String str1,String str2){
int result =0;
String m_s1 = null,m_s2 = null;
try {
m_s1 = new String(str1.getBytes(_FromEncode_),_ToEncode_);
m_s2 = new String(str2.getBytes(_FromEncode_),_ToEncode_);
} catch(Exception e){
return str1.compareTo(str2);
}
result = chineseCompareTo(m_s1,m_s2);
return result;
}
public static int getCharCode(String s){
if (s == null && s.equals(""))
return -1;
byte[] b = s.getBytes();
int value = 0;
for (int i = 0; i < b.length && i <= 2; i++){
value = value*100 + b[i]; //*100左移
}
return value;
}
public static int chineseCompareTo(String s1, String s2) {
int len1 = s1.length();
int len2 = s2.length();
int n = Math.min(len1, len2);
for (int i = 0; i < n; i++) {
int s1_code = getCharCode(s1.charAt(i) + "");
int s2_code = getCharCode(s2.charAt(i) + "");
if (s1_code*s2_code<0)
return Math.min(s1_code,s2_code);
if (s1_code != s2_code)
return s1_code - s2_code;
}
return len1 - len2;
}
public static String getBeginCharacter(String res) {
String a = res;
String result = "";
String current;
for(int i=0;i<a.length();i++){
current = a.substring(i,i+1);
if (gbkStringCompareTools.compare(current,"啊")<0 ) //字母,数字原样返回
result += current;
else if ((gbkStringCompareTools.compare(current, "啊")>=0) && (gbkStringCompareTools.compare(current,"座")) <= 0){
if (gbkStringCompareTools.compare(current,"匝") >= 0)
result += "z";
else if (gbkStringCompareTools.compare(current,"压") >=0)
result += "y";
else if (gbkStringCompareTools.compare(current,"昔") >=0)
result += "x";
else if (gbkStringCompareTools.compare(current,"挖") >=0)
result += "w";
else if (gbkStringCompareTools.compare(current,"塌") >=0)
result += "t";
else if (gbkStringCompareTools.compare(current,"撒") >=0)
result += "s";
else if (gbkStringCompareTools.compare(current,"然") >=0)
result += "r";
else if (gbkStringCompareTools.compare(current,"期") >=0)
result += "q";
else if (gbkStringCompareTools.compare(current,"啪") >=0)
result += "p";
else if (gbkStringCompareTools.compare(current,"哦") >=0)
result += "o";
else if (gbkStringCompareTools.compare(current,"拿") >=0)
result += "n";
else if (gbkStringCompareTools.compare(current,"妈") >=0)
result += "m";
else if (gbkStringCompareTools.compare(current,"垃") >=0)
result += "l";
else if (gbkStringCompareTools.compare(current,"喀") >=0)
result += "k";
else if (gbkStringCompareTools.compare(current,"击") >0)
result += "j";
else if (gbkStringCompareTools.compare(current,"哈") >=0)
result += "h";
else if (gbkStringCompareTools.compare(current,"噶") >=0)
result += "g";
else if (gbkStringCompareTools.compare(current,"发") >=0)
result += "f";
else if (gbkStringCompareTools.compare(current,"蛾") >=0)
result += "e";
else if (gbkStringCompareTools.compare(current,"搭") >=0)
result += "d";
else if (gbkStringCompareTools.compare(current,"擦") >=0)
result += "c";
else if (gbkStringCompareTools.compare(current,"芭") >=0)
result += "b";
else if (gbkStringCompareTools.compare(current,"啊") >=0)
result += "a";
}
}
return result;
}
}
#5
ding!!你的网站怎么进不去?
#1
jdk/bin/native2ascii
看看这个命令对你有帮助否
看看这个命令对你有帮助否
#2
问题得已解决了!谢谢张润福大师,帮我解决了,我的承诺不会改,请到我网站上下一下电子书籍,免费的,超过本,这几天我还要加,基本上全是java的!
#3
接分
#4
-
本来这个贴子在javaworld里也我也发了,因为这是公司交给我一个任务的关键地方,年底搞不好,我过年都不愉快,本想请各位高手帮我解答,我一介贫民,无以图报,只想将自己珍藏的本java,电子书籍给大家共享,目的也是为了开放源码,提供交流学习的平台,所以我将书籍会部上传到我网站了,全是免费的,有几本是bea,sun,公司的内部培训资料,是我个人参加培训时收藏的,我这些作法,没想到,javaworld意以“君子”之心度“小人”之腹,将的说的网站删除,并且还加了很多标记,"don't Don't be lured, please! ","Your advertisement for your website is really pretty smart. "这是我想都没想到的,开源,开源,学习,,我竟还不知道javaworld办站的宗旨是什么,我很痛心,(不要误会,我在这里不是在背地说javaworld坏话,只是发表一下内心的话)我觉得我们IT界就多应该多一个子"张润福大师,学习他的学习精神,学习他的奉献,学习他的无私,我真诚的希望大家,同样的it人,多一点气度,多一点包容,多一点理解,多一点支持,少一点猜疑,少一点抱怨,这样,程序人生,人生程序,也就无悔了。。。
现将将张大师的源码公开如下,旨在让大家少走一些弯路,:
package com.kefa.zhang.string;
/**
* <p>标题:中文字符串比较</p>
* <p>描述: 由于java使用unicode编码作为内吗,因此造成汉字的内码与中国国家汉字
* 内码标准不一致,从而导致了中文字符串得比较和排序相当困难。本类在分析以上
* 问题之后,解决的一级汉字(常用)汉字按照拼音排序的问题</p>
* <p>作者:张润福</p>
*
* */
public class gbkStringCompareTools {
private static String _FromEncode_ = "GBK";
private static String _ToEncode_ = "GBK";
protected gbkStringCompareTools() {
}
public static int compare(String str1,String str2){
int result =0;
String m_s1 = null,m_s2 = null;
try {
m_s1 = new String(str1.getBytes(_FromEncode_),_ToEncode_);
m_s2 = new String(str2.getBytes(_FromEncode_),_ToEncode_);
} catch(Exception e){
return str1.compareTo(str2);
}
result = chineseCompareTo(m_s1,m_s2);
return result;
}
public static int getCharCode(String s){
if (s == null && s.equals(""))
return -1;
byte[] b = s.getBytes();
int value = 0;
for (int i = 0; i < b.length && i <= 2; i++){
value = value*100 + b[i]; //*100左移
}
return value;
}
public static int chineseCompareTo(String s1, String s2) {
int len1 = s1.length();
int len2 = s2.length();
int n = Math.min(len1, len2);
for (int i = 0; i < n; i++) {
int s1_code = getCharCode(s1.charAt(i) + "");
int s2_code = getCharCode(s2.charAt(i) + "");
if (s1_code*s2_code<0)
return Math.min(s1_code,s2_code);
if (s1_code != s2_code)
return s1_code - s2_code;
}
return len1 - len2;
}
public static String getBeginCharacter(String res) {
String a = res;
String result = "";
String current;
for(int i=0;i<a.length();i++){
current = a.substring(i,i+1);
if (gbkStringCompareTools.compare(current,"啊")<0 ) //字母,数字原样返回
result += current;
else if ((gbkStringCompareTools.compare(current, "啊")>=0) && (gbkStringCompareTools.compare(current,"座")) <= 0){
if (gbkStringCompareTools.compare(current,"匝") >= 0)
result += "z";
else if (gbkStringCompareTools.compare(current,"压") >=0)
result += "y";
else if (gbkStringCompareTools.compare(current,"昔") >=0)
result += "x";
else if (gbkStringCompareTools.compare(current,"挖") >=0)
result += "w";
else if (gbkStringCompareTools.compare(current,"塌") >=0)
result += "t";
else if (gbkStringCompareTools.compare(current,"撒") >=0)
result += "s";
else if (gbkStringCompareTools.compare(current,"然") >=0)
result += "r";
else if (gbkStringCompareTools.compare(current,"期") >=0)
result += "q";
else if (gbkStringCompareTools.compare(current,"啪") >=0)
result += "p";
else if (gbkStringCompareTools.compare(current,"哦") >=0)
result += "o";
else if (gbkStringCompareTools.compare(current,"拿") >=0)
result += "n";
else if (gbkStringCompareTools.compare(current,"妈") >=0)
result += "m";
else if (gbkStringCompareTools.compare(current,"垃") >=0)
result += "l";
else if (gbkStringCompareTools.compare(current,"喀") >=0)
result += "k";
else if (gbkStringCompareTools.compare(current,"击") >0)
result += "j";
else if (gbkStringCompareTools.compare(current,"哈") >=0)
result += "h";
else if (gbkStringCompareTools.compare(current,"噶") >=0)
result += "g";
else if (gbkStringCompareTools.compare(current,"发") >=0)
result += "f";
else if (gbkStringCompareTools.compare(current,"蛾") >=0)
result += "e";
else if (gbkStringCompareTools.compare(current,"搭") >=0)
result += "d";
else if (gbkStringCompareTools.compare(current,"擦") >=0)
result += "c";
else if (gbkStringCompareTools.compare(current,"芭") >=0)
result += "b";
else if (gbkStringCompareTools.compare(current,"啊") >=0)
result += "a";
}
}
return result;
}
}
本来这个贴子在javaworld里也我也发了,因为这是公司交给我一个任务的关键地方,年底搞不好,我过年都不愉快,本想请各位高手帮我解答,我一介贫民,无以图报,只想将自己珍藏的本java,电子书籍给大家共享,目的也是为了开放源码,提供交流学习的平台,所以我将书籍会部上传到我网站了,全是免费的,有几本是bea,sun,公司的内部培训资料,是我个人参加培训时收藏的,我这些作法,没想到,javaworld意以“君子”之心度“小人”之腹,将的说的网站删除,并且还加了很多标记,"don't Don't be lured, please! ","Your advertisement for your website is really pretty smart. "这是我想都没想到的,开源,开源,学习,,我竟还不知道javaworld办站的宗旨是什么,我很痛心,(不要误会,我在这里不是在背地说javaworld坏话,只是发表一下内心的话)我觉得我们IT界就多应该多一个子"张润福大师,学习他的学习精神,学习他的奉献,学习他的无私,我真诚的希望大家,同样的it人,多一点气度,多一点包容,多一点理解,多一点支持,少一点猜疑,少一点抱怨,这样,程序人生,人生程序,也就无悔了。。。
现将将张大师的源码公开如下,旨在让大家少走一些弯路,:
package com.kefa.zhang.string;
/**
* <p>标题:中文字符串比较</p>
* <p>描述: 由于java使用unicode编码作为内吗,因此造成汉字的内码与中国国家汉字
* 内码标准不一致,从而导致了中文字符串得比较和排序相当困难。本类在分析以上
* 问题之后,解决的一级汉字(常用)汉字按照拼音排序的问题</p>
* <p>作者:张润福</p>
*
* */
public class gbkStringCompareTools {
private static String _FromEncode_ = "GBK";
private static String _ToEncode_ = "GBK";
protected gbkStringCompareTools() {
}
public static int compare(String str1,String str2){
int result =0;
String m_s1 = null,m_s2 = null;
try {
m_s1 = new String(str1.getBytes(_FromEncode_),_ToEncode_);
m_s2 = new String(str2.getBytes(_FromEncode_),_ToEncode_);
} catch(Exception e){
return str1.compareTo(str2);
}
result = chineseCompareTo(m_s1,m_s2);
return result;
}
public static int getCharCode(String s){
if (s == null && s.equals(""))
return -1;
byte[] b = s.getBytes();
int value = 0;
for (int i = 0; i < b.length && i <= 2; i++){
value = value*100 + b[i]; //*100左移
}
return value;
}
public static int chineseCompareTo(String s1, String s2) {
int len1 = s1.length();
int len2 = s2.length();
int n = Math.min(len1, len2);
for (int i = 0; i < n; i++) {
int s1_code = getCharCode(s1.charAt(i) + "");
int s2_code = getCharCode(s2.charAt(i) + "");
if (s1_code*s2_code<0)
return Math.min(s1_code,s2_code);
if (s1_code != s2_code)
return s1_code - s2_code;
}
return len1 - len2;
}
public static String getBeginCharacter(String res) {
String a = res;
String result = "";
String current;
for(int i=0;i<a.length();i++){
current = a.substring(i,i+1);
if (gbkStringCompareTools.compare(current,"啊")<0 ) //字母,数字原样返回
result += current;
else if ((gbkStringCompareTools.compare(current, "啊")>=0) && (gbkStringCompareTools.compare(current,"座")) <= 0){
if (gbkStringCompareTools.compare(current,"匝") >= 0)
result += "z";
else if (gbkStringCompareTools.compare(current,"压") >=0)
result += "y";
else if (gbkStringCompareTools.compare(current,"昔") >=0)
result += "x";
else if (gbkStringCompareTools.compare(current,"挖") >=0)
result += "w";
else if (gbkStringCompareTools.compare(current,"塌") >=0)
result += "t";
else if (gbkStringCompareTools.compare(current,"撒") >=0)
result += "s";
else if (gbkStringCompareTools.compare(current,"然") >=0)
result += "r";
else if (gbkStringCompareTools.compare(current,"期") >=0)
result += "q";
else if (gbkStringCompareTools.compare(current,"啪") >=0)
result += "p";
else if (gbkStringCompareTools.compare(current,"哦") >=0)
result += "o";
else if (gbkStringCompareTools.compare(current,"拿") >=0)
result += "n";
else if (gbkStringCompareTools.compare(current,"妈") >=0)
result += "m";
else if (gbkStringCompareTools.compare(current,"垃") >=0)
result += "l";
else if (gbkStringCompareTools.compare(current,"喀") >=0)
result += "k";
else if (gbkStringCompareTools.compare(current,"击") >0)
result += "j";
else if (gbkStringCompareTools.compare(current,"哈") >=0)
result += "h";
else if (gbkStringCompareTools.compare(current,"噶") >=0)
result += "g";
else if (gbkStringCompareTools.compare(current,"发") >=0)
result += "f";
else if (gbkStringCompareTools.compare(current,"蛾") >=0)
result += "e";
else if (gbkStringCompareTools.compare(current,"搭") >=0)
result += "d";
else if (gbkStringCompareTools.compare(current,"擦") >=0)
result += "c";
else if (gbkStringCompareTools.compare(current,"芭") >=0)
result += "b";
else if (gbkStringCompareTools.compare(current,"啊") >=0)
result += "a";
}
}
return result;
}
}
#5
ding!!你的网站怎么进不去?