Editing
Remove non breaking space
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
How to display or remove non-breaking space == Definition == # [https://en.wikipedia.org/wiki/Non-breaking_space Non-breaking space] ([https://zh.wikipedia.org/zh-tw/%E4%B8%8D%E6%8D%A2%E8%A1%8C%E7%A9%BA%E6%A0%BC 不換行空格], {{kbd | key=<nowiki>nbsp;</nowiki>}}) Sentence spacing # [https://en.wikipedia.org/wiki/Sentence_spacing_in_digital_media Sentence spacing in digital media - Wikipedia] e.g. {{kbd | key=<nowiki>&Nbsp; &Ensp; &Emsp;</nowiki>}} == How to remove the non-breaking space In PHP == Replace Non-breaking space with one whitespace using PHP<ref>[https://stackoverflow.com/questions/40724543/how-to-replace-decoded-non-breakable-space-nbsp php - How to replace decoded Non-breakable space (nbsp) - Stack Overflow]</ref> <pre> $result = str_replace("\xc2\xa0", ' ', $original_string); </pre> == How to display the non-breaking space In PHP == <pre> $input = '12345678' . hex2bin('c2a0'); echo $input . PHP_EOL; ## Result of above script: '12345678 ' (one whitespace at the end) echo bin2hex($input) . PHP_EOL; ## Result of above script: 3132333435363738c2a0 echo bin2hex('12345678') . PHP_EOL; ## Result of above script: 3132333435363738 (You mat notice the difference of script result is C2A0) </pre> == How to remove the non-breaking space In MySQL == <pre> SELECT REPLACE(`my_column`, UNHEX('C2A0'), '') FROM `my_table` </pre> == How to display the non-breaking space In MySQL == <pre> SELECT CONCAT('12345678', UNHEX('C2A0')) -- Result of above query: '12345678 ' (one whitespace at the end) SELECT HEX(CONCAT('12345678', UNHEX('C2A0'))) -- Result of above query: 3132333435363738C2A0 SELECT HEX('12345678') -- Result of above query: 3132333435363738 (You mat notice the difference of query result is C2A0) SELECT LENGTH('12345678') -- Result of above query: 8 SELECT LENGTH(CONCAT('12345678', UNHEX('C2A0'))) -- Result of above query: 10 </pre> [[Category:Data_hygiene]] [[Category:Data Science]] [[Category:PHP]] [[Category:MySQL]] [[Category:String manipulation]]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Template:Kbd
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information