use of org.mobicents.protocols.ss7.map.datacoding.GSMCharsetEncoder in project smscgateway by RestComm.
the class RxSmppServerSbb method recodeShortMessage.
protected byte[] recodeShortMessage(int dataCoding, String msg, byte[] udhPart) {
DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(dataCoding);
byte[] textPart;
if (msg != null) {
if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM8) {
textPart = msg.getBytes(isoCharset);
} else {
SmppEncoding enc;
if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM7) {
enc = smscPropertiesManagement.getSmppEncodingForGsm7();
} else {
enc = smscPropertiesManagement.getSmppEncodingForUCS2();
}
if (enc == SmppEncoding.Utf8) {
textPart = msg.getBytes(utf8Charset);
} else if (enc == SmppEncoding.Unicode) {
textPart = msg.getBytes(ucs2Charset);
} else {
GSMCharsetEncoder encoder = (GSMCharsetEncoder) gsm7Charset.newEncoder();
encoder.setGSMCharsetEncodingData(new GSMCharsetEncodingData(Gsm7EncodingStyle.bit8_smpp_style, null));
ByteBuffer bb = null;
try {
bb = encoder.encode(CharBuffer.wrap(msg));
} catch (CharacterCodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
textPart = new byte[bb.limit()];
bb.get(textPart);
}
}
} else {
textPart = new byte[0];
}
if (udhPart == null) {
return textPart;
} else {
byte[] res = new byte[textPart.length + udhPart.length];
System.arraycopy(udhPart, 0, res, 0, udhPart.length);
System.arraycopy(textPart, 0, res, udhPart.length, textPart.length);
return res;
}
}
use of org.mobicents.protocols.ss7.map.datacoding.GSMCharsetEncoder in project smscgateway by RestComm.
the class RxSipServerSbb method recodeShortMessage.
private byte[] recodeShortMessage(int dataCoding, String msg, byte[] udhPart) {
DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(dataCoding);
byte[] textPart;
if (msg != null) {
if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM8) {
textPart = msg.getBytes(isoCharset);
} else {
SmppEncoding enc;
if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM7) {
enc = smscPropertiesManagement.getSmppEncodingForGsm7();
} else {
enc = smscPropertiesManagement.getSmppEncodingForUCS2();
}
if (enc == SmppEncoding.Utf8) {
textPart = msg.getBytes(utf8Charset);
} else if (enc == SmppEncoding.Unicode) {
textPart = msg.getBytes(ucs2Charset);
} else {
GSMCharsetEncoder encoder = (GSMCharsetEncoder) gsm7Charset.newEncoder();
encoder.setGSMCharsetEncodingData(new GSMCharsetEncodingData(Gsm7EncodingStyle.bit8_smpp_style, null));
ByteBuffer bb = null;
try {
bb = encoder.encode(CharBuffer.wrap(msg));
} catch (CharacterCodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
textPart = new byte[bb.limit()];
bb.get(textPart);
}
}
} else {
textPart = new byte[0];
}
return textPart;
}
Aggregations