The sample code above uses a Unicode table as lookup for common accented characters to replace them with ASCII equivalents. While this may be efficient for short strings, as the original question states, with larger strings it may be more efficient to use a regular expression with a character class.
"Piqué".replace(/[ÄÖÜäöüß]/g, function(c) { return Latinise.latin_map[c] || c }) // -> "Pique"
The above is the detailed content of Is Regular Expression Replacement More Efficient Than Unicode Lookup for Large Strings with Accented Characters?. For more information, please follow other related articles on the PHP Chinese website!