Java tutorial
//package com.java2s; public class Main { /** * Convert an encoding name from the java encoding name * which often omits a hyphen in the name to the standard * XML encoding name with hyphens. * * @param encodingName The raw name of the encoding. * @return The corresponding XML encoding name. */ public static String toXmlEncodingName(String encodingName) { if (encodingName.matches("UTF\\d{1,2}")) { encodingName = encodingName.replace("UTF", "UTF-"); } else if (encodingName.matches("ISO\\d{4}\\.*")) { encodingName = encodingName.replace("ISO", "ISO-"); } return encodingName; } }