Comment

Comment by chrismorgan

> Use an HTML entity, a decimal code, or a hex code.

Please no: just write the character. <, & and (in quoted attributes) " or ' are the only characters that need to be encoded; a few others have arguable benefit to being encoded (most notably NO-BREAK SPACE), but most Unicode characters should just be put in literally. The days when you couldn’t be confident of the file encoding are past: your HTML is being served as UTF-8 (or in the rare case it isn’t, you should fix that instead of avoiding non-ASCII in the source).

Same deal with CSS (" and \ are the only ones you need to escape) and JavaScript (" or ' or `, as appropriate).

URLs? Occasionally you may encounter a legacy system where you need to percent-encode it yourself (similarly around punycoding internationalised domain names), but you can almost always (and thus, in my opinion, should) just write it and leave anything that wants it to be ASCII to perform the percent-encoding itself.

Excel I can’t comment on, but I presume you can just write "≈" and UNICHAR should almost never be used.

parent chrismorgan 10 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton