URL主机中可以显示哪些有效字符? [英] What are the valid characters that can show up in a URL host?

查看:75
本文介绍了URL主机中可以显示哪些有效字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些处理URL的代码,并且我想确保自己没有遗漏一些奇怪的情况...

I'm writing some code that processes URLs, and I want to make sure i'm not leaving some strange case out...

除了A-Z,0-9,-"和."以外,主机是否有任何有效字符?

Are there any valid characters for a host other than: A-Z, 0-9, "-" and "."?

(这包括可以在子域中的所有内容,等等.基本上是://和第一个/之间的任何内容)

(This includes anything that can be in subdomains, etc. Esentially, anything between :// and the first /)

谢谢!

推荐答案

请参阅对有效主机的限制名称:

主机名由一系列 与点连接的标签,按原样 所有域名 1 .例如, "en.wikipedia.org"是一个主机名.每个 标签必须在1到63之间 字符长,整个 主机名最大为255 字符.

Hostnames are composed of series of labels concatenated with dots, as are all domain names1. For example, "en.wikipedia.org" is a hostname. Each label must be between 1 and 63 characters long, and the entire hostname has a maximum of 255 characters.

RFC要求主机名的标签 只能包含ASCII字母"a" 通过"z"(不区分大小写), 数字"0"到"9",以及 连字号.主机名标签无法开始 或以连字符结尾.没有其他 符号,标点符号或 允许使用空格.

RFCs mandate that a hostname's labels may contain only the ASCII letters 'a' through 'z' (case-insensitive), the digits '0' through '9', and the hyphen. Hostname labels cannot begin or end with a hyphen. No other symbols, punctuation characters, or blank spaces are permitted.

这篇关于URL主机中可以显示哪些有效字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆