我有一个角度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();
});
});
}