我正在使用AWS .NET-SDK通过AWS SNS 服务发送 SMS 消息。到现在为止还挺好; 但是当我使用换行符时,我会?
在 SMS 中的换行符开始之前看到这个字符。在该字符之后,按预期添加换行符。?
没有这个角色有没有可能换行?
我也试过以下:
StringBuilder.AppendLine
,"\\n"
,"\\r\\n"
,@"\n"
,@"\r\n"
,Environment.NewLine
并将字符串编码为 UTF-8。
不起作用的示例:
// Create message string
var sb = new StringBuilder();
sb.AppendLine("Line1.");
sb.Append("Line2.\\n");
sb.AppendLine(Environment.NewLine);
sb.Append(@"Line4\n");
// Encode into UTF-8
var utf8 = UTF8Encoding.UTF8;
var stringBytes = Encoding.Default.GetBytes(sb.ToString());
var decodedString = utf8.GetString(stringBytes);
var message = decodedString;
// Create request
var publishRequest = new PublishRequest
{
PhoneNumber = "+491234567890",
Message = message,
Subject = "subject",
MessageAttributes = "Promotional"
};
// Send SMS
var response = await snsClient.PublishAsync("topic", message, "subject");