質問

Are there any dangers of not properly encoding html chars such as £ and & ?

I know if you want to write :

It was nice & cost £1

your html would be :

It was nice & cost £1

But is there any danger if your html was :

It was nice & cost £1

役に立ちましたか?

解決

You should encode the & as it has meaning in HTML and some parsers may not cope with it, even if most modern browsers can infer what you meant to do.

The £ however doesn't have to be encoded unless for some reason you have to encode your page as ASCII or if there's a risk of getting your character sets confused (e.g. UTF-8 vs ISO-8859-1).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top