Unity 字符串中英文、数字对齐

上代码

    string SetFormat(string str, int count)
    {
        if (string.IsNullOrEmpty(str))
        {
            return new string('*', count) { };
        }
        int len = count - Encoding.Default.GetByteCount(str);
        if (len <= 0)
        {
            return str;
        }
        else
        {
            if (len%3==0)
            {
                len += 1;//正好是3的整数倍的时候,	 就不管用了
            }
            return str + new string('*', len) + "	";
        }
    }

  其中的count应填3的整数倍,比如最长有5个汉字,则count填15,有10个汉字count就填30

看效果:

 原创不易,点赞支持一下

博客园Jason_c微信打赏码

如果本篇文档对你有帮助,打赏Jason_c根华子吧,他的私房钱被老婆没收了,呜呜!

原文地址:https://www.cnblogs.com/Jason-c/p/15422095.html