angular - 如何在角度 7 中将用户输入转换为 UCS2 并通过 Usb Gsm 调制解调器发送消息)
问题描述
我有一个 Angular 7 应用程序,它从用户那里获取输入(电话号码和消息)以使用电子串行端口发送短信。
我想在 UCS2 中编码电话号码和消息。我怎样才能将它转换为角度 7。
我找不到任何关于转换为 UCS2 的指南我已经尝试过 https://maketips.net/tip/239/convert-to-ucs2-and-from-ucs2-in-javascript
但我无法正确包含它,因为我是新手。
解决方案
我找到了解决方案。我尝试使用一个库 https://github.com/emilsedgh/modem
它运作良好。所以我不需要手动做任何事情(转换为 ucs2)。
let isElectron: boolean = window && window['process'] && window['process'].type;
if(isElectron){
modem.open("COM7",function(){
console.log('modem opened');
modem.sms({
receiver:"00923325200***",
text:"abc i am a msg",
encoding:'16bit'
}, function(err, sent_ids) {
console.log('>>', arguments);
if(err)
console.log('Error sending sms:', err);
else
console.log('Message sent successfully, here are reference ids:', sent_ids.join(','));
modem.close();
});
});
}
推荐阅读
- typescript - 在构建/编译期间将打字稿枚举转换为字符串
- python - Catboost 回归。函数外推
- html - 如何在 youtube 视频上隐藏标题、徽标和分享选项?
- c++ - 我将什么标志传递给 clang-cl 以获取 time.h、_CSTD、正确的 wint_t 和 mbstate_t?
- c# - Visual Studio 2017 for Mac 未能通过简单的新项目。怎么修?
- java - 如何使用 java 在 S3 中组合策略?
- java - 二维码扫描仪 - 空格字符问题
- vue.js - 如何在 Vue.js 中的单个列表元素上使用转换?
- python - 如何从 Python 中的信号处理程序中断阻塞系统调用函数?
- django - 模板渲染时出现“无法通过模型实例访问管理”错误