CheckData字符类方法(字符串操作)(2)

        /// <summary>
        /// 是否为文本类型
        /// </summary>
        /// <param name="fileType">File.ContentType</param>
        /// <returns></returns>
        public static bool IsTxt(string fileType)
        {
            return (fileType.ToLower() == getFileType(".txt"));
        }
        /// <summary>
        /// 人民币小写转为大写,可处理的最大单位为十亿
        /// </summary>
        /// <param name="rmb">rmb</param>
        /// <returns></returns>
        public static string MoneyLowerToUpper(double rmb)
        {
            string[] textArray = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
            string text = string.Format("{0:F2}", rmb);
            string text2 = "";
            if (rmb < 0)
            {
                text2 = "负";
            }
            text = text.Replace(".", "").Replace(",", "").Replace("-", "");
            for (int i = 0; i < text.Length; i++)
            {
                int index = text[i] - '0';
                string text3 = textArray[index];
                switch ((text.Length - i))
                {
                    case 1:
                        text2 = text2 + text3 + "分";
                        break;

                    case 2:
                        text2 = text2 + text3 + "角";
                        break;

                    case 3:
                        text2 = text2 + text3 + "元";
                        break;

                    case 4:
                        text2 = text2 + text3 + "拾";
                        break;

                    case 5:
                        text2 = text2 + text3 + "佰";
                        break;

                    case 6:
                        text2 = text2 + text3 + "仟";
                        break;

                    case 7:
                        text2 = text2 + text3 + "万";
                        break;

                    case 8:
                        text2 = text2 + text3 + "拾";
                        break;

                    case 9:
                        text2 = text2 + text3 + "佰";
                        break;

                    case 10:
                        text2 = text2 + text3 + "仟";
                        break;

                    case 11:
                        text2 = text2 + text3 + "亿";
                        break;

                    case 12:
                        text2 = text2 + text3 + "拾";
                        break;
                }
            }
            return text2;
        }
        /// <summary>
        /// 用于将长字串缩短到前4位,后加..(例如:珠海葆力有限公司,加了之后为:珠海葆力.. )
        /// </summary>
        /// <param name="txt">sour</param>
        /// <returns>后加..</returns>
        private string getShortName(string txt)
        {
            string objText =txt;
            if ( txt.Length > 4)
            {
                objText = txt.Substring(0,4) + "..";
            }
            return objText;
        }
        /// <summary>
        ///  对html编码eg < &lt; , > &gt;
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private string encodeHTML(string str)
        {
            str = str.Replace("<","&lt;");
            str = str.Replace(">","&gt;");
            return str;
        }
        /// <summary>
        ///  对html解码eg  &lt; <,  &gt; >  encodeHTML的反操作
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private string decodeHTML(string str)
        {
            str = str.Replace("&lt;","<");
            str = str.Replace("&gt;",">");
            return str;
        }

        /// <summary>
        ///  对html进行安全编码eg <  < , > >
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private string safeHTML(string str)
        {
            str = str.Replace("<","<");
            str = str.Replace(">","<");
            return str;
        }

        /// <summary>
        ///  对html进行安全解码eg   << ,  >> safeHTML的反操作
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private string unsafeHTML(string str)
        {
            str = str.Replace("<","<");
            str = str.Replace("<",">");
            return str;
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

rjzou2006

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值