4

How can I identify what characters are showing up as whitespace in a string?

The string is (There's actually a blank line before it, but it doesn't show up in StackOverflow's parser):

​  \n
​\n
\n

When I paste it in regex101.com to try to add a regex to eliminate this spacing/characters it pastes as:

enter image description here

... which explains why trim() is not seeing it as empty spaces.

How can I find out which characters are producing these bullets so I can trim them?

Ben
  • 60,438
  • 111
  • 314
  • 488
  • Those bullets are Unicode characters right? – bassxzero Dec 18 '17 at 13:45
  • [Unicode Whitespaces](http://www.fileformat.info/info/unicode/category/Zs/list.htm) ? [Unicode Bullet Points](https://stackoverflow.com/questions/12971187/what-would-be-the-unicode-character-for-big-bullet-in-the-middle-of-the-characte) ? – Alma Do Dec 18 '17 at 13:47
  • if you are on linux do this: https://unix.stackexchange.com/a/227838/237448 – Edwin Dec 18 '17 at 13:49
  • @AlmaDo In Python, I'd just use a comprehension to map `int` over the string. I'm not sure what the PHP equivalent would be. – Carcigenicate Dec 18 '17 at 13:49
  • Well, if you are using PHP 7.2 you can see what character code each character has in that string is by doing `array_map('mb_ord',preg_split("//u",$weirdString)));` in earlier versions there's "polyfills" for that at https://stackoverflow.com/questions/1365583/how-to-get-the-character-from-unicode-code-point-in-php this is assuming the string is a properly encoded unicode string . All bets are off otherwise – apokryfos Dec 18 '17 at 13:51

1 Answers1

1

What I would do is parse the string and get the ASCII character

$str = str_split('your string here');
foreach($str as $char) echo ord($char);

You'll then have the ASCII code of the character. You can theoretically work backwards from there

Machavity
  • 30,841
  • 27
  • 92
  • 100