带有%百分号的html的SMS正文文本使android应用崩溃

时间:2019-01-14 18:21:38

标签: android html html5 sms

每当我在短信HTML链接的正文中放入%时,例如: 短信(?或&取决于iOS android):

a href="sms:555555555?body=Hello123 % testing!"target="_parent">            
Click /a

它使我的消息传递应用程序在android上崩溃,但在iOS上很好。我也尝试对其进行编码,但这似乎没有用。有什么线索可以逃脱吗?

编辑:这仅在Google Messages中发生,Samsung Messages可以

3 个答案:

答案 0 :(得分:0)

尝试使用©<p>Copyright &copy;</p>

这样的符号书写

答案 1 :(得分:0)

尝试像这样编码百分比

a href="sms:555555555?body=Hello123 %25 testing!"target="_parent">      

答案 2 :(得分:0)

我遇到了同样的问题,花了很多时间,但是解决方案非常简单。 需要用以下其中之一替换“%”: percent sign variations

SMS正文编码功能:

function encodeSMSText(text) {
  const updatedText = text.replace(/%/g, String.fromCharCode(0xFF05));
   return encodeURIComponent(updatedText)
    .replace(/[!'()*]/g, function(c) {
      return '%' + c.charCodeAt(0).toString(16);
    });
}

相关问题