コード例 #1
0
        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));
        }
コード例 #2
0
 public static T DecodeAndDeserialize<T>(string value, string encodingName = "utf-8") =>
     DecodeAndDeserialize<T>(value, EncodingUtils.FindByName(encodingName));
コード例 #3
0
 public static string EncodeAndSerialize<T>(T value, string encodingName = "utf-8") =>
     SerializeAndEncode(value, EncodingUtils.FindByName(encodingName));
コード例 #4
0
 public static string DecodeUrl(string value, string encodingName = "utf-8") =>
     DecodeUrl(value, EncodingUtils.FindByName(encodingName));
コード例 #5
0
        public static string DecodeUrl(string value, string encodingName = "utf-8")
        {
            var encoding = EncodingUtils.FindByName(encodingName);

            return(DecodeUrl(value, encoding));
        }
コード例 #6
0
        public static string StreamToString(MemoryStream data, string encodingName = "utf-8")
        {
            var encoding = EncodingUtils.FindByName(encodingName);

            return(encoding?.GetString(data.ToArray()));
        }
コード例 #7
0
        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)));
        }