开发者

Whats the deal with the named html entity for $ ($)

开发者 https://www.devze.com 2023-04-11 15:17 出处:网络
I have a fairly simple question. There is a named HTML entity in most references for the dollar sign, and it is what you would expect it to be; $.

I have a fairly simple question. There is a named HTML entity in most references for the dollar sign, and it is what you would expect it to be; $.

But in other references, this is missing, and tell you only the numeric entity is available ($).

As I remember, the named entity didn't exist for a long time because the $ is part of the standard ASCII set. And due to this earlier/older versions of IE and other browsers don't support this entity.

So what's the deal with this currently? I am looking for what the support for the named entity is and why this wasn't supported in the first place...

Here's a reference to all the currency symbols where strangely eno开发者_Python百科ugh only the dollar doesn't have a named entity.

Here is a small example of what I am talking about when you use a dollar + int. And yes, I know that in this simple example I could have just escaped the dollar sign with a slash but believe me when I say that making it an entity when I save the string is the sanest solution in my case.

Regardless of my example, I am still curious what the support for the $ entity is.


The official list of entities doesn't list it, so I'd file it under “some browsers may have had support for it, don't rely on it, though.”

Generally, entities were needed to represent non-ASCII characters when the document character set was limited by ASCII. Nowadays with UTF-8 the most frequent character set on the web I think we can finally move past named entities and just use the characters directly.


The only sane solution is to use preg_quote() when using input for regular expressions. Otherwise you need to use html-enities for . \ + * ? [ ^ ] $ ( ) { } = ! < > | : - too.

0

精彩评论

暂无评论...
验证码 换一张
取 消