Here you can find the source of encodeText(String str, String fromEnc, String toEnc)
Parameter | Description |
---|---|
str | a source string |
fromEnc | source string encoding name |
toEnc | target encoding name |
public static String encodeText(String str, String fromEnc, String toEnc) throws UnsupportedEncodingException
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; public class Main { /**//from w w w. j a v a2s . c o m * Encode a string from the specific encoding name to other encoding name. * * @param str * a source string * @param fromEnc * source string encoding name * @param toEnc * target encoding name * @return encoded string. * @exception UnsupportedEncodingException * If the named encoding is not supported. */ public static String encodeText(String str, String fromEnc, String toEnc) throws UnsupportedEncodingException { return (str == null) ? null : new String(str.getBytes(fromEnc), toEnc); } /** * Encode a string from "8859_1" to "default.encoding". * * @param str * a source string * @return encoded string. * @exception UnsupportedEncodingException * If "default.encoding" is not supported. */ public static String encodeText(String str) throws UnsupportedEncodingException { if (getEncoding() == null) return str; return encodeText(str, "8859_1", getEncoding()); } /** * Default encoding name. * * @return Quics properties <code>quics.encoding</code> property value. If * the <code>quics.encoding</code> property value is null, return * null. */ public static String getEncoding() { return "euc-kr"; } }