Skip to content

Commit

Permalink
Merge pull request #103 from juliangut/fix/data_coding-encoding
Browse files Browse the repository at this point in the history
fix encoding based on data_coding
  • Loading branch information
juliangut authored May 29, 2019
2 parents ba22ff3 + 9a9a859 commit 3c0f843
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,10 @@ filters.message = {
return value;
}
var message = typeof value === 'string' ? value : value.message;
if (typeof message === 'string') {
var encoding = encodings.detect(message);
if (typeof message === 'string' && message) {
var encoded = false;
if (value.udh) {
var udhList = udhCoder.getUdh(value.udh);
var encoded = false;
for (var i = 0; i < udhList.length; i++) {
var udh = udhList[i];
if (udh[0] === 0x24 || udh[0] === 0x25) {
Expand All @@ -520,15 +519,19 @@ filters.message = {
break;
}
}
if (!encoded) {
if (message && this.data_coding === null) {
this.data_coding = consts.ENCODING[encoding];
}
message = encodings[encoding].encode(message);
}
} else {
if (message && this.data_coding === null) {
}
if (!encoded) {
var encoding = encodings.default;
if (this.data_coding === null) {
encoding = encodings.detect(message);
this.data_coding = consts.ENCODING[encoding];
} else if (this.data_coding !== consts.ENCODING.SMSC_DEFAULT) {
for (var key in consts.ENCODING) {
if (consts.ENCODING[key] === this.data_coding) {
encoding = key;
break;
}
}
}
message = encodings[encoding].encode(message);
}
Expand Down

0 comments on commit 3c0f843

Please sign in to comment.