standardizeText

standardizeText ( string text , mixed _typeOfStandardization ) : string

Clear a text replacing all strange caracters, malencoded caracters, html caracters, etc.

Example


console(standardizeText("

\u003d un élephant¸ yep

")) //->

= un élephant, yep
console(standardizeText("

\x23 un élephant 

", "url")) //-> # un elephant!

Parameters

text

to clean

_typeOfStandardization (optional)

• 0 : make 1 pass for linearize all possible problematic caracters without touching blank spaces (no trim)
• false : make 1 pass for linearize all possible problematic caracters
• 2 : make 2 passes for linearize all possible problematic caracters
• 3 : make 2 passes for linearize all possible problematic caracters, non ascii chars and linearize blanks without touching "new line" chars
• true (default) : linearize all possible problematic caracters (2 passes), clear, non ascii chars and linearize blanks
• "xml" : like true, but for XML content. It removes <![CDATA[.....]]> and replace <img> by <picture> and <imgs> by <pictures>
• "url" : for url rewriting. No accent and all caracters other than A-Z and 0-9 replaced by "-". Keep case.
• "file" : for file names. All not autorized caracters for filenames (\/:*?\"<>|) are replaced by "_". Keep case.
• You can clean text for Prestashop with these values : "prestashop_combinaion", "prestashop_attribute", "prestashop_category", "prestashop_manufacturer", "prestashop_supplier", "prestashop_feature", "prestashop_feature_value"
• "remove_unusual_characters" : remove other caracters than alphanumerics and ÀÂÃÄÅÇÈÉÊËÌÎÒÓÔÕÖÙÚÛÜàáâãäåçèéêëìíîïðòóôõöùúûüýÿŒœ.!:;,?./%*$}=+)]\[_|-({#"& ]<>°