MyUtil语句程序把utf-8编码转换为tomcat自带可读的iso-8859-1编码简单快捷

XuanCode 2020-06-19 05:58:06
package utils;

import java.io.UnsupportedEncodingException;

public class MyUtil {
public static String toUnicode(String s)
{
if(s == null || s.equals("")) {
return s="";
}
try {
s = new String(s.getBytes("iso-8859-1"),"utf-8");
//把utf-8编码转换为tomcat
} catch(UnsupportedEncodingException e)
{
s = ""; e.printStackTrace();
}

return s;
}

public static int toInt(String s)//字符串转整体
{
if(s == null || s.equals("")) {
s = "0";
}
int i = 0;
try {
i = Integer.parseInt(s);
}catch(Exception e)
{
i = 0;
e.printStackTrace();
...全文
9 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

6,129

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 新技术前沿
社区管理员
  • 新技术前沿社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧