zuzacat Posted November 5, 2010 Share Posted November 5, 2010 Hi all, In my string I have hidden characters that has a shape of square. When I print the string, it shows questions mark. When I opened it with notepad, it show a square shaped character. I want to remove this character in my strings. I have searched the web. Somebody says its carriage return but i think it is not. Could you please help me with this issue. Thanks alot. Quote Link to comment https://forums.phpfreaks.com/topic/217832-removing-square-shaped-hidden-characters/ Share on other sites More sharing options...
rwwd Posted November 5, 2010 Share Posted November 5, 2010 Well if you posted the code that's being affected we could possibly assist. Also, make sure that the editor you are using isn't adding extra chars... Rw Quote Link to comment https://forums.phpfreaks.com/topic/217832-removing-square-shaped-hidden-characters/#findComment-1130611 Share on other sites More sharing options...
zuzacat Posted November 5, 2010 Author Share Posted November 5, 2010 When I paste the string to here, the character becomes hidden. But the character is a small square that is seen on notepad++ Quote Link to comment https://forums.phpfreaks.com/topic/217832-removing-square-shaped-hidden-characters/#findComment-1130618 Share on other sites More sharing options...
harristweed Posted November 5, 2010 Share Posted November 5, 2010 Sounds like an encoding issue, have a look at 'mb_detect_encoding' in php manual Quote Link to comment https://forums.phpfreaks.com/topic/217832-removing-square-shaped-hidden-characters/#findComment-1130622 Share on other sites More sharing options...
litebearer Posted November 5, 2010 Share Posted November 5, 2010 might look here http://www.phpro.org/examples/Strip-All-Non-Alphanumeric-Characters-Except-Space-With-PHP.html Quote Link to comment https://forums.phpfreaks.com/topic/217832-removing-square-shaped-hidden-characters/#findComment-1130632 Share on other sites More sharing options...
zuzacat Posted November 5, 2010 Author Share Posted November 5, 2010 Thank you litebearer, This function is ok but as our string contains turkish characters, with this function it removes them too. Repeating the problem, When I look at database, I see nothing in string but when I copy it to a text editor, I see the hidden char there. Below is the picture that the square hidden character seen. I am outputting the result with XML, becouse of that hidden character it puts "?" (question mark) for that hidden square like character. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/217832-removing-square-shaped-hidden-characters/#findComment-1130653 Share on other sites More sharing options...
zuzacat Posted November 8, 2010 Author Share Posted November 8, 2010 Ok I found a way I strip all nonalphanumeric characters and allow some of them. preg_replace('/[^a-zA-Z0-9\s\'\"\şıüğçöİŞÜĞÇÖ\.\<>_-]/', '', $string); But I allow <br><p> tags in my string so I add "<" and ">" but could not add "/" character. May somebody help me to add this slash "/" character in my regular expression to allow it. Quote Link to comment https://forums.phpfreaks.com/topic/217832-removing-square-shaped-hidden-characters/#findComment-1131715 Share on other sites More sharing options...
Pikachu2000 Posted November 8, 2010 Share Posted November 8, 2010 You're using the forward slash as your delimiter, so you'll need to escape in in the patten, or use a different delimiter. Quote Link to comment https://forums.phpfreaks.com/topic/217832-removing-square-shaped-hidden-characters/#findComment-1131848 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.