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

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

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

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

/// <summary>
        /// <函數(shù):Encode>
        /// 作用:將字符串內(nèi)容轉(zhuǎn)化為16進(jìn)制數(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進(jìn)制數(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)文章

最新評論

雅江县| 通江县| 永济市| 阜宁县| 白山市| 察哈| 阿合奇县| 漠河县| 呼伦贝尔市| 宝山区| 宁安市| 呼玛县| 和田县| 陵川县| 本溪市| 襄樊市| 东兰县| 鲜城| 通州区| 大足县| 筠连县| 吉隆县| 澄城县| 巴林左旗| 武隆县| 蓬溪县| 衡东县| 瑞昌市| 平舆县| 永平县| 黔西县| 宁都县| 荔波县| 钦州市| 虹口区| 资源县| 洛阳市| 德州市| 临桂县| 嘉善县| 郁南县|