C2a0 And 20 String Comparision - Php - Stack Overflow
-
- Home
- Questions
- Tags
- Users
- Companies
- Labs
- Jobs
- Discussions
- Collectives
-
Communities for your favorite technologies. Explore all Collectives
- Teams
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Try Teams for free Explore Teams - Teams
-
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about TeamsGet early access and see previews of new features.
Learn more about Labs c2a0 and 20 string comparision Ask Question Asked 8 years, 10 months ago Modified 2 years, 6 months ago Viewed 3k times Part of PHP Collective 6I have two utf-8 strings:
- one saved as variable in php file (saved in UTF-8)
- another gets externally from another with regular expression.
When I compare those two same space-separated strings, the result is false, meaning that they are not the same.
- The string I saved as a variable is rendered as 20 with bin2hex (ascii encoded space symbol)
- The string I got externally, processed with mb_strtolower($string, 'utf-8') is rendered as c2a0 with bin2hex (utf-8 space)
My questions is:
- Why when I save in utf-8 string not fully encoded as utf-8 (meaning space in ascii)?
- How to get rid of that problem?
- 6 c2a0 is a no-break space whereas 20 is a space. – bobble bubble Commented Jan 21, 2016 at 14:18
1 Answer
Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 4As said in the comments c2a0 is a no-break space and 20 is normal space
Since you can see the problem in bin2hex you could:
$str = hex2bin(str_replace('c2a0', '20', bin2hex($str)));or to put that another way:
$str = preg_replace('~\xc2\xa0~', ' ', $str); // typo corrected Share Improve this answer Follow edited May 8, 2022 at 21:25 user2373839 13 bronze badges answered Sep 23, 2016 at 12:25 Ad WicksAd Wicks 3003 silver badges10 bronze badges Add a comment |Your Answer
Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Draft saved Draft discardedSign up or log in
Sign up using Google Sign up using Email and Password SubmitPost as a guest
Name EmailRequired, but never shown
Post Your Answer DiscardBy clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Not the answer you're looking for? Browse other questions tagged
or ask your own question. PHP Collective Join the discussion This question is in a collective: a subcommunity defined by tags with relevant content and experts.- The Overflow Blog
- Your docs are your infrastructure
- Featured on Meta
- More network sites to see advertising test [updated with phase 2]
- We’re (finally!) going to the cloud!
- Call for testers for an early access release of a Stack Overflow extension...
Linked
1 Mongodb search with space between wordRelated
2653 How do I check if a string contains a specific word? 2322 How do you parse and process HTML/XML in PHP? 1345 What's the difference between utf8_general_ci and utf8_unicode_ci? 1703 startsWith() and endsWith() functions in PHP 1195 Check whether a string matches a regex in JS 1154 What's the difference between UTF-8 and UTF-8 with BOM? 165 How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()? 866 How to count string occurrence in string? 78 Force encode from US-ASCII to UTF-8 (iconv)Hot Network Questions
- Publishing corollaries of previously published results
- Inheritance Tax: the Estate or the Beneficiaries?
- How Do Copulas Provide Insight Into Dependence Between Random Variables?
- Study("somewhere")
- Will a laptop battery that stays connected to its charger be damaged?
- What is another word for when someone’s statement lacks integrity or meaning?
- Student is almost always late, and expects me to re-explain everything he missed
- What's a good way to append a nonce to ciphertext in Python for AES GCM in Python?
- Identifying a TNG episode where Dr. Pulaski instructs another doctor on a sling
- Is BNF grammar in TeXbook correct?
- Configure Linux to regularly sync cached data to disk
- Counting birds outside my house
- How do I add a trusted check constraint quickly
- If scent means a pleasant smell, why do we say "lovely scent" or "sweet scent"?
- What does GB Shaw mean when he says "like the butcher's wife in the old catch" here?
- Is there any penalty for providing half cover to another creature?
- Different projection matrices, don't understand how to proceed
- Why is it safe to soak an electric motor in isopropyl alcohol but not distilled water?
- What powers do police have to force people onto trains?
- Why don't routers answer ARP requests for IP addresses they can handle even if they aren't assigned that IP address themselves?
- Syllables of noun ‹cavalier›?
- Late 70s/Early 80s android made-for-TV movie
- Does synonymy seep down to the fragments of theories?
- How do different observers decide if they are looking at the same thing?
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
lang-phpTừ khóa » C2 A0 Vs 20
-
Thread: Url Encode %A0 Vs. %20 - Dynamic Drive
-
Non-breaking Space - Wikipedia
-
HTML URL Encoding Reference - W3Schools
-
Replace Non-breaking Space UTF-8 (C2 A0) | Notepad++ Community
-
HTML URL-encoding Reference
-
C2 A0 -> NO-BREAK SPACE With Special Spaces In UTF-8 Encoding
-
Unicode/UTF-8-character Table
-
Non-breaking Space C2 A0 (U+00A0) Causing Problems With CSS ...
-
Desktop Vs Mobile Vs Tablet%C2%A0 Market Share Cyprus
-
Desktop Vs Mobile Vs Tablet%C2%A0 Market Share Kuwait
-
HTML | URL Encoding - GeeksforGeeks