Java×?·??ˉ±à??ó?×a??
ê±??:2011-02-03 leizhimin
Java±àò?ê±oò£??á??java???tμ?±à??°′?????¨±à???ò??£¨?μí3??è?μ?£?±à??×a???aUnicode2¢?ó??μ??ú′??D??DD±àò??£
??????3?ò???Java×a??1¤??£???óD2aê?1y£?o?o?£o
package??lavasoft.common;
import??org.apache.commons.logging.Log;
import??org.apache.commons.logging.LogFactory;
import??java.io.*;
/**
*??×a??1¤??£?è????§3????t?¢×?·?′?μ?×a??
*
*??@author??Administrator??2009-11-29??16:14:21
*/
public??class??EncodingToolkit??{
???????????????? private??static??Log??log??=??LogFactory.getLog(EncodingToolkit.class);
???????????????? public??static??void??main(String[]??args)??{
???????????????????????????????? String??han??=??"oo";
???????????????????????????????? System.out.println("---------");
???????????????? }
???????????????? /**
?????????????????? *????×?·?′???D?±à??
?????????????????? *
?????????????????? *??@param??text??????????×?·?′?
?????????????????? *??@param??resEncoding???′±à??
?????????????????? *??@param??newEncoding??D?±à??
?????????????????? *??@return????D?±à??oóμ?×?·?′?
?????????????????? */
???????????????? public??static??String??reEncoding(String??text,??String??resEncoding,??String??newEncoding)??{
???????????????????????????????? String??rs??=??null;
???????????????????????????????? try??{
???????????????????????????????????????????????? rs??=??new??String(text.getBytes(resEncoding),??newEncoding);
???????????????????????????????? }??catch??(UnsupportedEncodingException??e)??{
???????????????????????????????????????????????? log.error("?áè????t?aò????ú′?×?·?′?꧰ü£?꧰ü?-òòê?ê1ó?á?2??§3?μ?×?·?±à??");
???????????????????????????????????????????????? throw??new??RuntimeException(e);
???????????????????????????????? }
???????????????????????????????? return??rs;
???????????????? }
???????????????? /**
?????????????????? *????D?±à??Unicode×?·?′?
?????????????????? *
?????????????????? *??@param??text???????????′×?·?′?
?????????????????? *??@param??newEncoding??D?μ?±à??
?????????????????? *??@return?????¨±à??μ?×?·?′?---www.bianceng.cn
?????????????????? */
???????????????? public??static??String??reEncoding(String??text,??String??newEncoding)??{
???????????????????????????????? String??rs??=??null;
???????????????????????????????? try??{
???????????????????????????????????????????????? rs??=??new??String(text.getBytes(),??newEncoding);
???????????????????????????????? }??catch??(UnsupportedEncodingException??e)??{
???????????????????????????????????????????????? log.error("?áè????t?aò????ú′?×?·?′?꧰ü£?꧰ü?-òòê?ê1ó?á?2??§3?μ?×?·?±à??"??+??newEncoding);
???????????????????????????????????????????????? throw??new??RuntimeException(e);
???????????????????????????????? }
???????????????????????????????? return??rs;
???????????????? }
???????????????? /**
?????????????????? *????±????t??D?±
|