TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Beware of the Unicode no-break space (0xC2 0xA0)

11 pointsby vicjicamaalmost 4 years ago
Hi all!<p>Yesterday I saw a very strange behavior while working with some tags, I thought this was a bug!<p>Can you spot the difference? (https:&#x2F;&#x2F;jsfiddle.net&#x2F;vbjtcf3d&#x2F;)<p>&lt;div pagews-snapshot=&quot;true&quot; referenceid=&quot;remotemkt.listws.app&quot; snapshotid=&quot;snapshot&#x2F;board-companies&quot; &gt;&lt;&#x2F;div&gt;<p>the other ( https:&#x2F;&#x2F;jsfiddle.net&#x2F;q9d08xp1&#x2F; )<p>&lt;div pagews-snapshot=&quot;true&quot; referenceid=&quot;remotemkt.listws.app&quot; snapshotid=&quot;snapshot&#x2F;board-companies&quot; &gt;&lt;&#x2F;div&gt;<p>Both looks exactly the same!, but only one is working....<p>It turn out that it was an unicode character issue, the spacing between the non working tag was using the unicode non-breaking space (0xC2 0xA0), when I replaced the spaces with the regular space character (0x20) everything worked again.<p>I think that I copied this tag from an email, I will be extra careful in the future for this kind of issues.<p>It took me a while to find out this, I hope this could help anyone, if your attributes are null and you are sure that they are present check you html with a hex editor.<p>Let me know your thoughts

5 comments

johnboilesalmost 4 years ago
If you use Evernote, at some point in the last year or so they started rewriting their spaces an non breaking space characters. I get tripped up almost weekly by some command or code I pasted from my notes
评论 #27898783 未加载
评论 #27916679 未加载
mikewarotalmost 4 years ago
Thanks for the heads up. Life sure seemed simpler when it was just ASCII and American English to worry about. ;-)
kazinatoralmost 4 years ago
The character is U+00A0.<p>C2 A0 is the UTF-8 encoding.
qwerty456127almost 4 years ago
IMHO all the parsers should update to address this. A space is still a space even if it&#x27;s a non-breaking one.
ad404b8a372f2b9almost 4 years ago
Another thing that trips me up regularly is BOM bytes at the start of text files, it can be really hard to debug if you don&#x27;t know about them.