0

I need a way to convert a string with bullet points, special characters like: ⃝©£€™≠≤⓫⓫₼₧ῲἏɘ to a plain text. Where all of that gets removed.

Basically, i have a field where the user can copyPaste a full page of Word that includes weird characters , so i need a way to convert the string that he copyPaste to plaint text and remove that characters.

Edit: I put a "@" as part of spcial characters. I remove it.

  • 1
    You'll need to quantify "special characters" further. Your example includes an `@` which I personally wouldn't consider a special character. Do you want to remove everything that isn't a US English letter, digit, space and certain punctuation marks? – Chris Haas May 10 '21 at 17:40
  • If you haven't heard of "regular expressions", I would suggest reading about them now, because they're probably the solution to your problem. Beware, though, you'll need to make sure you know the character encoding of the text (hopefully [UTF-8 all the way through](https://stackoverflow.com/q/279170/157957)). – IMSoP May 10 '21 at 18:06
  • Why not set your encodings correctly and not have to remove the "weird characters" at all? See the link @IMSoP posted above. – Sammitch May 10 '21 at 19:08

1 Answers1

0

You need to define your special characters in an array and remove them from the string:

$input_string = "some t⓫⓫₼₧ῲext";
$special_chars = ["£", "€", "™", "≠", "≤", "⓫", "⓫", "₼", "₧", "ῲ", "Ἇ", "ɘ"];
$replace_with = [];
print str_replace($special_chars, $replace_with, $input_string);
amrezzd
  • 1,787
  • 15
  • 38