Safe delimiter for dsv of email addresses
I need to use/store a delimiter separated value string (not csv) of email addresses. I need to choose a delimiter that is safe.
Eg bar@foo.com,baz@foo.com,
- comma in this eg is unsafe as it's valid within an email address.
It seems that almost anything is allowed in an email address, especially now with internationalized email addresses.
What is a safe delimiter to use without jumping through hoops because of corner cases? I can't find a character in the RFC which which is expressly invalid (but there are lots of email related related RFCs, so I'm not sure which to consult).
Where/how will you be storing the string and what will the delimiter be used for?
You could use a non-visible ascii character such as the CR (Ascii 13) or Tab (Ascii 9).
I originally used because that is an escape character, however it is allowed if escaped. @MatWalker's answer recommends stuff like CR or LF etc, but those are allowed too, if they are escaped.
Escaping and replacing and unescaping got a bit complicated. So right now I'm using control character STX
(ie "Start of Text", decimal 2).
Although the RFC doesn't mention (from what I've seen) whether control charactes are valid/invalid, there doesn't seem to be anything that makes it a bad choice. It does say that control chars are "discouraged", but not prohibited for header fields.
链接地址: http://www.djcxy.com/p/16592.html上一篇: 更改searchView阈值
下一篇: 电子邮件地址的dsv的安全分隔符