Skip to content

removeNoneASCIICharacters

Mike Byrne edited this page Mar 14, 2023 · 1 revision

description

Introduced 3.1.0

Removes non ASCII characters from a string.

Because it removes all non ASCII characters, it maybe removing more than you intend. You may instead want to remove all non printable characters - replaceNonPrintableCharacters

requires

  • nothing

parameters

  • str - required - string to remove non ASCII characters from

returns

  • string minus non ASCII characters

example usage:

let str = removeNoneASCIICharacters(` ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜   ‌‍‎‏–—‘’‚“”„†‡‰‹›€`); // '"&<>'

Using default input from www.soscisurvey.de/tools/view-chars:

let str = removeNoneASCIICharacters(`See what's hidden in your string… or be​hind`); // Seewhat's hidden in your string or behind

Removes accented characters but not emoji:

let str = removeNoneASCIICharacters(`Hernán Cortés de Monroy y Pizarro Altamirano 🇪🇸`); // `Hernn Corts de Monroy y Pizarro Altamirano 🇪🇸`

Will remove characters from none Latin languages:

let str = removeNoneASCIICharacters(`Είναι πλέον κοινά παραδεκτό ότι ένας αναγνώστης αποσπάται από το περιεχόμενο που διαβάζει`); // ``