Class CharsetUtil

java.lang.Object
net.sf.basedb.util.charset.CharsetUtil

public class CharsetUtil extends Object
Helper class for working with charsets and enabling the UTF-8 with fallback charsets: X-UTF-8_with_ISO-8859-1_fallback X-UTF-8_with_windows-1252_fallback
Since:
3.15
Author:
nicklas
  • Field Details

    • UTF8_WITH_FALLBACK

      public static final CharsetProvider UTF8_WITH_FALLBACK
      The provider that is providing the UTF-8 with fallback characeter sets.
  • Constructor Details

    • CharsetUtil

      public CharsetUtil()
  • Method Details

    • getCharset

      public static Charset getCharset(String name)
      Get a character set by name. This will first look if it is a UTF-8 with fallback charset and if not check the system Charset.forName(String).
    • getAllCharsets

      public static List<String> getAllCharsets(boolean includeFallbacks)
      Get all charsets that Config.getAllCharsets() returns and optionally include the fallback charsets. Note that the fallback charsets are automatically sorted just below the UTF-8 character set.
    • asEnumeration

      public static Enumeration<String,String> asEnumeration(Collection<String> charsets)
      Convert charset names to an enumeration with display-friendly key/title pairs.