internal static byte[] EncodeCString(string str, SmppEncodingService smppEncodingService) { if (str == null) { str = ""; } return(smppEncodingService.GetBytesFromCString(str)); }
/// <summary> /// Sets the given TLV(as a string)into the table. /// This will reverse the byte order in the tag for you (necessary for encoding). /// If the value is null, the parameter TLV will be removed instead. /// </summary> /// <param name="tag">The tag for this TLV.</param> /// <param name="val">The value of this TLV.</param> public void SetOptionalParamString(Tag tag, string val, bool nullTerminated = false) { if (val == null) { this.RemoveOptionalParameter(tag); } else { var bytes = vSmppEncodingService.GetBytesFromCString(val, nullTerminated); SetOptionalParamBytes(tag, bytes); } }
/// <summary> /// Sets the given TLV(as a string)into the table. /// This will reverse the byte order in the tag for you (necessary for encoding). /// If the value is null, the parameter TLV will be removed instead. /// </summary> /// <param name="tag">The tag for this TLV.</param> /// <param name="val">The value of this TLV.</param> public void SetOptionalParamString(Tag tag, string val, bool nullTerminated = false) { if (val == null) { this.RemoveOptionalParameter(tag); } else { var bytes = vSmppEncodingService.GetBytesFromCString(val); // Add a null byte to the end if needed. if (nullTerminated) { Array.Resize(ref bytes, bytes.Length + 1); } SetOptionalParamBytes(tag, bytes); } }