public static string ReencodeString(string value, string sourceEncodingName = "", string targetEncodingName = "utf-8") { var sourceEncoding = string.IsNullOrEmpty(sourceEncodingName) ? Encoding.Default : EncodingUtils.FindByName(sourceEncodingName); var targetEncoding = EncodingUtils.FindByName(targetEncodingName); return(ReencodeString(value, sourceEncoding, targetEncoding)); }
public static T DecodeAndDeserialize<T>(string value, string encodingName = "utf-8") => DecodeAndDeserialize<T>(value, EncodingUtils.FindByName(encodingName));
public static string EncodeAndSerialize<T>(T value, string encodingName = "utf-8") => SerializeAndEncode(value, EncodingUtils.FindByName(encodingName));
public static string DecodeUrl(string value, string encodingName = "utf-8") => DecodeUrl(value, EncodingUtils.FindByName(encodingName));
public static string DecodeUrl(string value, string encodingName = "utf-8") { var encoding = EncodingUtils.FindByName(encodingName); return(DecodeUrl(value, encoding)); }
public static string StreamToString(MemoryStream data, string encodingName = "utf-8") { var encoding = EncodingUtils.FindByName(encodingName); return(encoding?.GetString(data.ToArray())); }
public static MemoryStream StringToStream(string data, string encodingName = "utf-8") { var encoding = EncodingUtils.FindByName(encodingName); return(encoding == null ? null : new MemoryStream(encoding.GetBytes(data ?? string.Empty))); }