寻找文件名中允许但电子邮件地址中不允许的字符......任何线索?

Looking for a character that is allowed in Filenames but not allowed in email addresses... Any clue?

我正在尝试创建与电子邮件地址关联的多个 html 文件。但是由于“@”不能用在文件名中,为了避免混淆,我试图用电子邮件地址中通常不会存在的字符替换它。

有什么想法吗?

谢谢!

我相信“~”是用于此目的。

根据此处的 link,只要特殊字符不在开头或结尾,几乎所有 ASCII 字符都允许出现在电子邮件地址中。

What characters are allowed in an email address?

逗号和 semi-colon 不允许出现在电子邮件地址中,但出现在大多数文件系统的文件名中。

,(逗号)中的任意一个; (semi-colon) <>(尖括号)[](方括号)或 "(双引号)应该适用于大多数情况。

由于带引号的字符串中允许使用这些字符,因此您可以将“@”替换为无效的序列,例如连续三个双引号。

根据the RFC

within a quoted string, any ASCII graphic or space is permitted without blackslash-quoting except double-quote and the backslash itself.

你可以有一个电子邮件 abc。"~~~".def@rst.xyz。但是你不能有 abc.""".def@rst.xyz;它必须是 abc.""".def@rst.xyz。因此您可以安全地使用“””代替文件名中的@。

但是,RFC 还说

While the above definition for Local-part is relatively permissive, for maximum interoperability, a host that expects to receive mail SHOULD avoid defining mailboxes where the Local-part requires (or uses) the Quoted-string form or where the Local-part is case- sensitive.

应该意味着“...那个 在特定情况下可能存在正当理由 特定行为是可以接受的,甚至是有用的,但完整的 应理解其含义并仔细权衡个案 在实施之前..." RFC2119

因此,虽然“””可以工作,但您看到一封带引号的电子邮件的机会是否值得为此费心设计?如果不是,则使用其中一个字符。