示例#1
0
        private void To()
        {
            //base64
            var character = "ABCDEFG";
            var base64    = "WkhJ5qGG5p6257uE5Lu2";

            Console.WriteLine("base64");
            Console.WriteLine("     ToBase64Encode:{0}", ZConvert.ToBase64Encode(character));
            Console.WriteLine("     ToBase64Decode:{0}", ZConvert.ToBase64Decode(base64));
            //timestamp
            var timestamp = "1609430400";

            Console.WriteLine("timestamp");
            Console.WriteLine("     ToDateTimeFromTimeStamp:{0}", ZConvert.ToDateTimeFromTimeStamp(timestamp));
            Console.WriteLine("     ToTimeStampFromDateTime:{0}", ZConvert.ToTimeStampFromDateTime(DateTime.Now));
            //enum
            Console.WriteLine("enum");
            Console.WriteLine("     ToIntFromEnum:{0}", ZConvert.ToIntFromEnum(TimeStampUnit.Millisecond));
            //ip
            Console.WriteLine("ip");
            Console.WriteLine("     ToIpFromLong:{0}", ZConvert.ToIpFromLong(2130706433));
            Console.WriteLine("     ToLongFromIp:{0}", ZConvert.ToLongFromIp("127.0.0.1"));
            //unicode
            character = "中文";
            var unicode = "\\u8fd9\\u662f\\u0055\\u006e\\u0069\\u0063\\u006f\\u0064\\u0065\\u7f16\\u7801";

            Console.WriteLine("unicode");
            Console.WriteLine("     ToUnicodeEncode:{0}", ZConvert.ToUnicodeEncode(character));
            Console.WriteLine("     ToUnicodeDecode:{0}", ZConvert.ToUnicodeDecode(unicode));
            Console.WriteLine();
            Console.WriteLine();
        }
示例#2
0
 /// <summary>
 /// Unicode编码字符串(Unicode encoding a string)
 /// </summary>
 /// <param name="value">字符串</param>
 /// <returns></returns>
 public static string UnicodeEncode(string value)
 {
     return(ZConvert.ToUnicodeEncode(value));
 }