Class HTMLUtils

java.lang.Object
org.omegat.util.HTMLUtils

public final class HTMLUtils extends Object
  • Method Details

    • isLatinLetter

      public static boolean isLatinLetter(int ch)
      Returns true if a char is a latin letter
    • isDecimalDigit

      public static boolean isDecimalDigit(int ch)
      Returns true if a char is a decimal digit
    • isHexDigit

      public static boolean isHexDigit(int ch)
      Returns true if a char is a hex digit
    • entitiesToChars

      public static String entitiesToChars(String input)
      Converts HTML entities in the given input string to their corresponding characters. This handles numeric and named entities, resolving them to their appropriate Unicode representations. If an entity is unresolvable or malformed, it is left unchanged in the output string.
      Parameters:
      input - the input string that may contain HTML entities to be converted
      Returns:
      a string with HTML entities replaced by their corresponding characters
    • charsToEntities

      public static String charsToEntities(String str, @Nullable String encoding, Collection<String> shortcuts)
      Converts characters that must be converted (< > & ' ' (nbsp)) into HTML entities.
      Parameters:
      str - The string to convert
      encoding - The output encoding. May be null (all characters are assumed to be supported).
      shortcuts - A collection of tag-like strings (<foo>) that will be "protected", i.e. they will not be escaped as entities.
    • getSpacePrefix

      public static String getSpacePrefix(String input, boolean compressWhitespace)
    • getSpacePostfix

      public static String getSpacePostfix(String input, boolean compressWhitespace)