android - 带有百分比符号的 html 的 SMS 正文文本会导致 android 应用程序崩溃
问题描述
每当我在我的短信 html 链接的正文中添加一个 % 时,例如:短信(?或 & 分隔取决于 ios android):
a href="sms:555555555?body=Hello123 % testing!"target="_parent">
Click /a
它使我在 android 上的消息传递应用程序崩溃,但在 iOS 上它很好。我也尝试对其进行编码,但这似乎不起作用。关于如何逃避这个的任何线索?
编辑:这只发生在谷歌信息上,三星信息是好的
解决方案
我遇到了同样的问题并花了很多时间,但解决方案非常简单。需要将 '%' 替换为以下之一: 百分号变化
短信正文编码功能:
function encodeSMSText(text) {
const updatedText = text.replace(/%/g, String.fromCharCode(0xFF05));
return encodeURIComponent(updatedText)
.replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
推荐阅读
- sql-server - 如何使用 SQL 查询检索数据,该查询将存储在 powershell 变量中的用户列表作为输入?
- ios - `Realm` 需要 CocoaPods 版本 `>= 1.10`,您当前的版本 `1.8.3` 不满足此要求
- python-3.x - 将元组列表传递给函数参数而不修改函数定义
- java - 如何使用 java 和 google gmail-api 获取收到的邮件?
- reactjs - 当用户在 reactjs 中更改路由时,如何从组件中取消以前的 api?
- python - stdout 从 shell 获取前多于 1 行
- postgresql - 有没有办法在 postgres 序列中保留一个范围?
- python-3.x - 如何正确测试带有参数的assertRaised?
- javascript - html JavaScript 中的复选框,即使在页面重新加载时也保持选中状态
- javascript - Javascript setDate() 错误