zoukankan      html  css  js  c++  java
  • 全角转半角

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace talefox.ShareLib
    {
        public class Characters
        {
            /// <summary>
            /// 全角转半角
            /// </summary>
            /// <param name="c">需要转换的字符,当为半角时不转换</param>
            /// <returns>半角字符</returns>
            public static char DoubleByteToHalfAngle(char c)
            {
                char[] cs = new char[] { c};
                byte[] bs = System.Text.Encoding.Unicode.GetBytes(cs, 0, 1);

                if (bs.Length == 2)
                {
                    if (bs[1] == 255)
                    {
                        bs[0] = (byte)(bs[0] + 32);
                        bs[1] = 0;
                        cs[0] = System.Text.Encoding.Unicode.GetChars(bs)[0];
                    }
                }
                return cs[0];
            }
        }
    }

  • 相关阅读:
    http
    VUE-1
    AJAX
    html常用标签
    CSS网页布局
    概念整理3
    SEO
    概念整理2
    var
    概念整理
  • 原文地址:https://www.cnblogs.com/talefox/p/1322583.html
Copyright © 2011-2022 走看看