最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

字符串和十六進制之間的轉(zhuǎn)換方法實例

 更新時間:2013年11月06日 16:05:01   作者:  
這篇文章介紹了字符串和十六進制之間的轉(zhuǎn)換方法實例,有需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

/// <summary>
        /// <函數(shù):Encode>
        /// 作用:將字符串內(nèi)容轉(zhuǎn)化為16進制數(shù)據(jù)編碼,其逆過程是Decode
        /// 參數(shù)說明:
        /// strEncode 需要轉(zhuǎn)化的原始字符串
        /// 轉(zhuǎn)換的過程是直接把字符轉(zhuǎn)換成Unicode字符,比如數(shù)字"3"-->0033,漢字"我"-->U+6211
        /// 函數(shù)decode的過程是encode的逆過程.
        /// </summary>
        /// <param name="strEncode"></param>
        /// <returns></returns>
        public static string Encode(string strEncode)
        {
            string strReturn = "";//  存儲轉(zhuǎn)換后的編碼
            foreach (short shortx in strEncode.ToCharArray())
            {
                strReturn += shortx.ToString("X4");
            }
            return strReturn;
        }
        /// <summary>
        /// <函數(shù):Decode>
        ///作用:將16進制數(shù)據(jù)編碼轉(zhuǎn)化為字符串,是Encode的逆過程
        /// </summary>
        /// <param name="strDecode"></param>
        /// <returns></returns>
        public static string Decode(string strDecode)
        {
            string sResult = "";
            for (int i = 0; i < strDecode.Length / 4; i++)
            {
                sResult += (char)short.Parse(strDecode.Substring(i * 4, 4), global::System.Globalization.NumberStyles.HexNumber);
            }
            return sResult;
        }

相關(guān)文章

最新評論

栾川县| 成都市| 和平县| 霍州市| 固始县| 临沧市| 高阳县| 柳林县| 寿阳县| 安吉县| 吉安县| 汝城县| 余江县| 宜都市| 江陵县| 嫩江县| 焉耆| 靖边县| 苗栗县| 永登县| 安康市| 咸宁市| 德惠市| 高台县| 凤庆县| 浙江省| 定日县| 平潭县| 清流县| 色达县| 尤溪县| 封开县| 南涧| 金川县| 贡山| 龙海市| 平远县| 米脂县| 通辽市| 左云县| 泰来县|