Roave / shorty

An asynchronous SMPP client and server built on Node.js. Shorty is sponsored and maintained by SMS Cloud, a subsidiary of Roave
http://roave.com/
GNU General Public License v3.0
92 stars 52 forks source link

Client: automatically detect charset and convert and split sms by charset with overlenght to concat sms #12

Open Dexus opened 10 years ago

Dexus commented 10 years ago

my idee is that the client should automatically convert the charset (ie UTF-8 with only GSM 03.38 chars) to GSM 03.38 or if need (Unicode with other chars as in GSM 03.38) to USC2 charset.

If the message lenght is longer than 160/70(USC2) than split to messages with 153/63 chars.

with header support like in php-smpp https://github.com/onlinecity/php-smpp/blob/master/smppclient.class.php#L280

CSMS_8BIT_UDH = 153 chars in concat mode CSMS_16BIT_TAGS = 152 chars in concat mode CSMS_PAYLOAD = for me unknown; not possible to test with my partners

some encodings in smpp (5.0) https://github.com/farhadi/node-smpp/blob/master/lib/defs.js#L227

example like: https://github.com/pshon/shorty/commit/791e1b11257794e61b9c1683c489ed6530acb82d

Dexus commented 10 years ago

unicode (ucs-2[be] / UTF-16BE) is not direct possible with node... need build a converter with iconv or simlar

eugenehp commented 10 years ago

Here is some snippet for you:

var Iconv  = require('iconv').Iconv;
var toucs = new Iconv('UTF-8', 'UCS-2BE');

and you convert it like so:

message = toucs.convert(message);

Don't forget to install dependencies first: npm install iconv

There also another library you may want to try: iconv-lite

Xerkus commented 8 years ago

I don't think shorty will provide such conversion, it belongs to the shorty consumer scope