c#中System.Net.Mail.Attachment.CreateAttachmentFromString的默认编码是什么?
What is the default encoding used in System.Net.Mail.Attachment.CreateAttachmentFromString in c#?
您可以使用 System.Net.Mail.Attachment.CreateAttachmentFromString
而无需像这样指定编码 Attachment.CreateAttachmentFromString(content, name)
,在这种情况下将使用什么编码来对内容字符串进行编码?
According to the documentation,它是 ASCII 或 UTF-8:
If the content is in ASCII format then the character encoding is set to ASCII. For all other formats, the character encoding is set to utf-8. The default media type is plain text.
If the content is not in ASCII format and the encoding is null, utf-8 encoding is used.
您可以使用 System.Net.Mail.Attachment.CreateAttachmentFromString
而无需像这样指定编码 Attachment.CreateAttachmentFromString(content, name)
,在这种情况下将使用什么编码来对内容字符串进行编码?
According to the documentation,它是 ASCII 或 UTF-8:
If the content is in ASCII format then the character encoding is set to ASCII. For all other formats, the character encoding is set to utf-8. The default media type is plain text.
If the content is not in ASCII format and the encoding is null, utf-8 encoding is used.