Package org.omegat.util
Class HTMLUtils
java.lang.Object
org.omegat.util.HTMLUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcharsToEntities(String str, @Nullable String encoding, Collection<String> shortcuts) Converts characters that must be converted (< > & ' ' (nbsp)) into HTML entities.static StringentitiesToChars(String input) Converts HTML entities in the given input string to their corresponding characters.static StringgetSpacePostfix(String input, boolean compressWhitespace) static StringgetSpacePrefix(String input, boolean compressWhitespace) static booleanisDecimalDigit(int ch) Returns true if a char is a decimal digitstatic booleanisHexDigit(int ch) Returns true if a char is a hex digitstatic booleanisLatinLetter(int ch) Returns true if a char is a latin letter
-
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
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 convertencoding- 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
-
getSpacePostfix
-