1

I have some white spaces in my database displaying like the attached image. i believe they are not being recognized as white spaces because i have used the following to remove them but they all failed.

1. preg_replace( '/^((?=^)(\s*))|((\s*)(?>$))/si', '',$data['home']);
2. trim($data['home']);
3. str_replace

(' ','',$data['home']);

How do i remove them please?

how do i remove those black things that have question marks in them

Itay
  • 16,601
  • 2
  • 51
  • 72
  • Check the character set of the data you want to remove. Once identified, you can replace it. Can you paste a sample of the character in your question. – Viswanath Polaki Aug 11 '20 at 10:52
  • Those are not white spaces. They are bytes or sequences or bytes that are not valid characters or characters that do not have a representation in the font. The font rendering engine uses a special character instead. – axiac Aug 11 '20 at 10:53
  • @ViswanathPolaki i attached a picture of the character – oscarkontrol Aug 11 '20 at 11:00
  • Does this answer your question? [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – CBroe Aug 11 '20 at 11:10

1 Answers1

0

You can remove all the non UTF-8 characters from a string with the following code

line=line.decode('utf-8','ignore').encode("utf-8")

Source: Delete every non utf-8 symbols from string

Here you can see line variable is first decoded and then encoded. This will remove your strange looking characters from your string.

Viswanath Polaki
  • 1,357
  • 1
  • 10
  • 19