Class TextUtil

java.lang.Object
com.itextpdf.io.util.TextUtil

public final class TextUtil extends Object
This file is a helper class for internal usage only. Be aware that its API and functionality may be changed in future.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
     
    static String
    charToString(char ch)
     
    static char[]
    convertFromUtf32(int codePoint)
    Converts a UTF32 code point value to a char array with the corresponding character(s).
    static String
    convertFromUtf32(int[] text, int startPos, int endPos)
    /** Converts a UTF32 code point sequence to a String with the corresponding character(s).
    static char[]
    Converts a UTF32 code point value to a char array with the corresponding character(s).
    static int
    convertToUtf32(char[] text, int idx)
    Converts a unicode character in a character array to a UTF 32 code point value.
    static int
    convertToUtf32(char highSurrogate, char lowSurrogate)
    Returns the code point of a UTF32 character corresponding with a high and a low surrogate value.
    static int[]
     
    static int
    convertToUtf32(String text, int idx)
    Converts a unicode character in a String to a UTF32 code point value
    static char
    highSurrogate(int codePoint)
     
    static boolean
    isCarriageReturnFollowedByLineFeed(GlyphLine glyphLine, int carriageReturnPosition)
     
    static boolean
    isDiacritic(int codePoint)
    Checks if the passed code point corresponds to diacritic.
    static boolean
     
    static boolean
    isMark(Glyph glyph)
     
    static boolean
    isNewLine(char c)
    Check if a character is a newline by checking if it's integer value is a newline in unicode
    static boolean
    isNewLine(int unicode)
    Check if a character is a newline by checking if it's integer value is a newline in unicode
    static boolean
    Check if a glyph is a newline by checking if it's unicode value is a newline
    static boolean
     
    static boolean
     
    static boolean
    isSpace(Glyph glyph)
     
    static boolean
     
    static boolean
    Check if the value of a character belongs to a certain interval that indicates it's the higher part of a surrogate pair.
    static boolean
    Check if the value of a character belongs to a certain interval that indicates it's the lower part of a surrogate pair.
    static boolean
    isSurrogatePair(char[] text, int idx)
    Checks if two subsequent characters in a character array are the higher and the lower character in a surrogate pair (and therefore eligible for conversion to a UTF 32 character).
    static boolean
    isSurrogatePair(String text, int idx)
    Checks if two subsequent characters in a String are the higher and the lower character in a surrogate pair (and therefore eligible for conversion to a UTF 32 character).
    static boolean
     
    static boolean
     
    static boolean
     
    static char
    lowSurrogate(int codePoint)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TextUtil

      private TextUtil()
  • Method Details

    • isDiacritic

      public static boolean isDiacritic(int codePoint)
      Checks if the passed code point corresponds to diacritic.
      Parameters:
      codePoint - the code point to check
      Returns:
      true if passed code point is diacritic, false otherwise
    • isSurrogateHigh

      public static boolean isSurrogateHigh(char c)
      Check if the value of a character belongs to a certain interval that indicates it's the higher part of a surrogate pair.
      Parameters:
      c - the character
      Returns:
      true if the character belongs to the interval
    • isSurrogateLow

      public static boolean isSurrogateLow(char c)
      Check if the value of a character belongs to a certain interval that indicates it's the lower part of a surrogate pair.
      Parameters:
      c - the character
      Returns:
      true if the character belongs to the interval
    • highSurrogate

      public static char highSurrogate(int codePoint)
    • lowSurrogate

      public static char lowSurrogate(int codePoint)
    • isSurrogatePair

      public static boolean isSurrogatePair(String text, int idx)
      Checks if two subsequent characters in a String are the higher and the lower character in a surrogate pair (and therefore eligible for conversion to a UTF 32 character).
      Parameters:
      text - the String with the high and low surrogate characters
      idx - the index of the 'high' character in the pair
      Returns:
      true if the characters are surrogate pairs
    • isSurrogatePair

      public static boolean isSurrogatePair(char[] text, int idx)
      Checks if two subsequent characters in a character array are the higher and the lower character in a surrogate pair (and therefore eligible for conversion to a UTF 32 character).
      Parameters:
      text - the character array with the high and low surrogate characters
      idx - the index of the 'high' character in the pair
      Returns:
      true if the characters are surrogate pairs
    • convertToUtf32

      public static int convertToUtf32(char highSurrogate, char lowSurrogate)
      Returns the code point of a UTF32 character corresponding with a high and a low surrogate value.
      Parameters:
      highSurrogate - the high surrogate value
      lowSurrogate - the low surrogate value
      Returns:
      a code point value
    • convertToUtf32

      public static int convertToUtf32(char[] text, int idx)
      Converts a unicode character in a character array to a UTF 32 code point value.
      Parameters:
      text - a character array that has the unicode character(s)
      idx - the index of the 'high' character
      Returns:
      the code point value
    • convertToUtf32

      public static int convertToUtf32(String text, int idx)
      Converts a unicode character in a String to a UTF32 code point value
      Parameters:
      text - a String that has the unicode character(s)
      idx - the index of the 'high' character
      Returns:
      the codepoint value
    • convertToUtf32

      public static int[] convertToUtf32(String text)
    • convertFromUtf32

      public static char[] convertFromUtf32(int codePoint)
      Converts a UTF32 code point value to a char array with the corresponding character(s).
      Parameters:
      codePoint - a Unicode value
      Returns:
      the corresponding char array
    • convertFromUtf32

      public static String convertFromUtf32(int[] text, int startPos, int endPos)
      /** Converts a UTF32 code point sequence to a String with the corresponding character(s).
      Parameters:
      text - a Unicode text sequence
      startPos - start position of text to convert, inclusive
      endPos - end position of txt to convert, exclusive
      Returns:
      the corresponding characters in a String
    • convertFromUtf32ToCharArray

      public static char[] convertFromUtf32ToCharArray(int codePoint)
      Converts a UTF32 code point value to a char array with the corresponding character(s).
      Parameters:
      codePoint - a Unicode value
      Returns:
      the corresponding characters in a char arrat
    • charToString

      public static String charToString(char ch)
    • isNewLine

      public static boolean isNewLine(Glyph glyph)
      Check if a glyph is a newline by checking if it's unicode value is a newline
      Parameters:
      glyph - glyph to check
      Returns:
      True if the glyph represents a newline, false otherwise
    • isNewLine

      public static boolean isNewLine(char c)
      Check if a character is a newline by checking if it's integer value is a newline in unicode
      Parameters:
      c - character to check
      Returns:
      True if the character represents a newline, false otherwise
    • isNewLine

      public static boolean isNewLine(int unicode)
      Check if a character is a newline by checking if it's integer value is a newline in unicode
      Parameters:
      unicode - unicode value to check
      Returns:
      True if the character represents a newline, false otherwise
    • isCarriageReturnFollowedByLineFeed

      public static boolean isCarriageReturnFollowedByLineFeed(GlyphLine glyphLine, int carriageReturnPosition)
    • isSpaceOrWhitespace

      public static boolean isSpaceOrWhitespace(Glyph glyph)
    • isWhitespace

      public static boolean isWhitespace(Glyph glyph)
    • isNonBreakingHyphen

      public static boolean isNonBreakingHyphen(Glyph glyph)
    • isSpace

      public static boolean isSpace(Glyph glyph)
    • isUni0020

      public static boolean isUni0020(Glyph g)
    • isNonPrintable

      public static boolean isNonPrintable(int c)
    • isWhitespaceOrNonPrintable

      public static boolean isWhitespaceOrNonPrintable(int code)
    • isLetterOrDigit

      public static boolean isLetterOrDigit(Glyph glyph)
    • isMark

      public static boolean isMark(Glyph glyph)
    • charsetIsSupported

      public static boolean charsetIsSupported(String charsetName)