char a = 'a';
int b = (int)a;
System.err.println(" a ascii is " + b); 运行结果:
a ascii is 97。
int b = (int)a;
System.err.println(" a ascii is " + b); 运行结果:
a ascii is 97。
解决方案 »
- java生成word的问题
- 关于jsp页面跟mysql数据库的问题
- 关于静态工厂的一个问题
- Java能复制带图表的excel文件的Sheet的吗?
- 关于Conn cannot be resolved to a type
- resin服务器要采用request.getRequestDispatcher.forward从servlet转发到jsp应怎样配置
- JSP网站本地环境搭建报错
- 介绍几本实战的书,兄弟们
- 收取sina的邮件的发送时间getSentDate()和getReceivedDate()怎么都是空(NULL)?
- java开源论坛有推荐的么?
- 那有InfoReport下载
- 请给一个实现思路
比如:
String str="人生";
然后我想将它转成--》 人生不知该怎么转哪?
* Convert native string to ISO-8859-1 encoding string
* @param token Token
* @param value String
* @return String
*/
public static String toIso88591String(String nativeEncoding, String value) {
String newValue = value;
String defaultEncoding = "iso-8859-1";
if (!defaultEncoding.equals(nativeEncoding)) {
try {
newValue = new String(newValue.getBytes(nativeEncoding),
defaultEncoding);
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
}
return newValue;
}
String valueAfter = toIso88591String("gb2312", "中国");
{
String s1 = "";
if(s != null && !s.equals(""))
{
int i = s.length();
for(int j = 0; j < i; j++)
{
char c = s.charAt(j);
s1 = s1 + "&#x" + Integer.toHexString(c) + ";";
} }
return s1;
}