我有一个 Angular 7 应用程序,它从用户那里获取输入(电话号码和消息)以使用电子串行端口发送短信。
我想在 UCS2 中编码电话号码和消息。我怎样才能将它转换为角度 7。
我找不到任何关于转换为 UCS2 的指南我已经尝试过 https://maketips.net/tip/239/convert-to-ucs2-and-from-ucs2-in-javascript
但我无法正确包含它,因为我是新手。
我有一个 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();
});
});
}