HTML Entities & Charset & URL Encode

HTML Entities

Character entities are used to display reserved characters in HTML.

字符实体用于显示HTML保留的字符。许多通用键盘上没有的数学符号、科技符号、货币符号等,也可以通过HTML实体来表示。


有两种写法:

&entity_name;

OR

&#entity_number;


The advantage of using an entity name, instead of a number, is that the name is easier to remember.

使用前者(实体名字)的优势是便于记忆。
The disadvantage is that browsers may not support all entity names, but the support for numbers (十进制十六进制)is good.

缺点是,浏览器不一定支持所有的实体名称。

If you use an HTML entity name, or number, the character will always display correctly. This is independent of what character set (encoding) your page uses!

无论用实体名还是数字,字符都会正确显示,这个独立于网页所使用的编码字符集。


Tip: Remember that browsers will always truncate spaces in HTML pages. If youwrite 10 spaces in your text, the browser willremove 9 of them. To add real spaces to your text, you can use the   character entity.

为了在文本中加入1个以上的空格,可以使用   字符实体

此外,Entity names是 case sensitive 大小写敏感的!


HTML Charset

为正确显示网页,浏览器必须知道使用哪种 character set (character encoding)字符集。

ASCII was the first character encoding standard (also called character set). It define 127 different alphanumeric 含有字母数字的

characters that could be used on the internet.

ASCII supported numbers (0-9), English letters (A-Z), and some special characters like ! $ + - ( ) @ < > .

ANSI (Windows-1252) was the default character set for Windows (up to Windows 95). It supported 256 different codes.

ISO-8859-1, was the default character set for HTML 4. It also supported 256 different codes.

Because ANSI and ISO was too limited, the default character encoding was changed to UTF-8 in HTML5(All HTML 4 processors also support UTF-8).

UTF-8 Unicode covers (almost) all the characters and symbols in the world.


HTML5

<meta charset="UTF-8">

HTML4

<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">

HTML URL(Uniform Resource Locators)

URL 也就是 web address。

URL 格式

scheme://host.domain:port/path/filename

  • scheme - defines the type of Internet service. (most common type is http
  • host - defines the domain host (default host for http is www)
  • domain - defines the Internet domain name, likew3schools.com
  • port - defines the port number at the host (default port number for http is 80)
  • path - defines a path at the server (If omitted, the document must be stored at theroot directory of the site)
  • filename - defines the name of a document/resource

URL Encoding

URLs can only be sent over the Internet using the ASCII character-set.

Since URLs often contain characters outside the ASCII set (因为URL 中经常含有ASCII字符集以外的字符,比如请求参数里含有字母、带有音标,如法语西语字母)

URL encoding converts characters into a format that can be transmitted over the Internet.

此时必须使用URL编码把这些字符转换为可以在因特网中传输的形式。

URL encoding replaces non ASCII characters with a "%" followed by two hexadecimal digits.

URL编码用一个 % 紧跟着两个十六进制数字来替换URL中非ASCII字符。

URLs cannot contain spaces, normally replaces a space with a plus (+) sign or%20.

URL中不能含有空格,通常用一个加号替换空格。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值