List of utility methods to do Charset Create
Charset | getCharset(String enc) Returns the Java Charset that should be used for the provided encoding Charset charset = encodingToCharsetCache.get(enc); if (charset == null) { charset = Charset.forName(enc); encodingToCharsetCache.put(enc, charset); return charset; |
Charset | getCharset(String encoding) get Charset return ((null == encoding || "".equals(encoding.trim())) ? Charset.forName(DEF_ENCODING) : Charset.forName(encoding)); |
Charset | getCharset(String encoding) get Charset Charset charset = (Charset) charsets.get(encoding); if (charset == null) { charset = Charset.forName(encoding); charsets.put(encoding, charset); return charset; |
Charset | getCharset(String name) Gets a charset, throwing the java.io exception and not the java.nio exception if an error occurs. try { return Charset.forName(name); } catch (IllegalCharsetNameException e) { throw new UnsupportedEncodingException("Charset " + name + " not found."); } catch (UnsupportedCharsetException e) { throw new UnsupportedEncodingException("Charset " + name + " not found."); |
Charset | getCharsetForSortOrder(final int sortOrder) Retrieves the CharsetInfo instance asociated with the specified sort order.
String name = sortMap[sortOrder];
return Charset.forName(name);
|
String | getCharsetFromContent(URL url) get Charset From Content InputStream stream = url.openStream(); byte chunk[] = new byte[2048]; int bytesRead = stream.read(chunk); if (bytesRead > 0) { String startContent = new String(chunk); String pattern = "\\<meta\\s*http-equiv=[\\\"\\']content-type[\\\"\\']\\s*content\\s*=\\s*[\"']text/html\\s*;\\s*charset=([a-z\\d\\-]*)[\\\"\\'\\>]"; Matcher matcher = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(startContent); if (matcher.find()) { ... |
String | getCharsetFromContentType(String contentType) Parse out a charset from a content type header. if (contentType == null) return null; Matcher m = charsetPattern.matcher(contentType); if (m.find()) { String charset = m.group(1).trim(); if (Charset.isSupported(charset)) return charset; charset = charset.toUpperCase(Locale.ENGLISH); ... |
String | getCharsetFromContentType(String contentType) get Charset From Content Type if (contentType == null) { return null; Matcher m = charsetPattern.matcher(contentType); if (m.find()) { String charset = m.group(1).trim(); charset = charset.replace("charset=", ""); if (charset.isEmpty()) ... |
String | getCharsetFromContentTypeString(String contentType) get Charset From Content Type String if (contentType != null) { String pattern = "charset=([a-z\\d\\-]*)"; Matcher matcher = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(contentType); if (matcher.find()) { String charset = matcher.group(1); if (Charset.isSupported(charset)) { return charset; return null; |
Charset[] | getCharsetList(List Returns the supplied List as an array, and guarantees that the specified actual Charset is contained. if (actualCharset == null || availableCharsets.contains(actualCharset)) { return (Charset[]) availableCharsets.toArray(new Charset[availableCharsets.size()]); } else { List<Charset> resultList = new ArrayList<Charset>(); resultList.addAll(availableCharsets); resultList.add(actualCharset); return (Charset[]) resultList.toArray(new Charset[resultList.size()]); |