Module tvbrowser
Package util.i18n

Class WritingConversion


  • public class WritingConversion
    extends java.lang.Object
    Author:
    Jo
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String reduceToASCIILetters​(java.lang.String string, boolean replaceUnsupportedChars)
      Reduces String to ASCII letters by removing punctuation and redundant whitespaces and replacing non-ASCII letters with similar ASCII letters if available.
      (currently supported: ISO-8859-1 to -4, ISO-8859-9, -10, ISO 8859-13 to -16, Windows-1252, MacRoman)
      static java.lang.String removeDiacriticalMarks​(java.lang.String string)
      Remove any diacritical marks (accents like ç, ñ, é, etc) from the given string.
      static java.lang.String removeRedundantWhitespaces​(java.lang.String string)
      Replace whitespaces with a single space
      static java.lang.String replaceLatinDerivedLetters​(java.lang.String string)
      Replaces non-ASCII latin derived letters with similar ASCII letters if available.
      (currently supported: ISO-8859-1 to -4, ISO-8859-9, -10, ISO 8859-13 to -16, Windows-1252, MacRoman)
      static java.lang.String replacePunctuation​(java.lang.String string, java.lang.String replaceString)
      Replace punctuation (!"
      • Methods inherited from class java.lang.Object

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

      • WritingConversion

        public WritingConversion()
    • Method Detail

      • removeDiacriticalMarks

        public static java.lang.String removeDiacriticalMarks​(java.lang.String string)
        Remove any diacritical marks (accents like ç, ñ, é, etc) from the given string. from http://balusc.blogspot.com/2006/10/stringutil.html no copyright since it's too simple ;-)
        Parameters:
        string - The string to remove diacritical marks from.
        Returns:
        The string with removed diacritical marks, if any.
      • replaceLatinDerivedLetters

        public static java.lang.String replaceLatinDerivedLetters​(java.lang.String string)
        Replaces non-ASCII latin derived letters with similar ASCII letters if available.
        (currently supported: ISO-8859-1 to -4, ISO-8859-9, -10, ISO 8859-13 to -16, Windows-1252, MacRoman)
        Parameters:
        string - The string to replace non-ASCII letters.
        Returns:
        The string with all supported non-ASCII letters replaced.
      • replacePunctuation

        public static java.lang.String replacePunctuation​(java.lang.String string,
                                                          java.lang.String replaceString)
        Replace punctuation (!"#$%&'()*+,-./:;<=>@[\]^_`{|}~¿¡ dashes and quotation marks) with a given string
        Parameters:
        string - The string to replace punctuation from.
        replaceString - The string to replace the punctuation with
        Returns:
        The string with removed punctuation, if any.
      • removeRedundantWhitespaces

        public static java.lang.String removeRedundantWhitespaces​(java.lang.String string)
        Replace whitespaces with a single space
        Parameters:
        string - The string to replace whitespaces from.
        Returns:
        The string with replaced whitespaces, if any.
      • reduceToASCIILetters

        public static java.lang.String reduceToASCIILetters​(java.lang.String string,
                                                            boolean replaceUnsupportedChars)
        Reduces String to ASCII letters by removing punctuation and redundant whitespaces and replacing non-ASCII letters with similar ASCII letters if available.
        (currently supported: ISO-8859-1 to -4, ISO-8859-9, -10, ISO 8859-13 to -16, Windows-1252, MacRoman)
        Parameters:
        string - The string to reduce.
        replaceUnsupportedChars - If true, all characters that can't be replaced with ASCII letters will be replaced with an underscore.
        Returns:
        The reduced string.