日期:2014-05-18 浏览次数:21147 次
Text = Encoding.Default.GetString(
    Encoding.Default.GetBytes("a中d12文cd"), 0, 6); //a中d12
------解决方案--------------------
    // 把一个“unicode字符串”格式化为全角字符占2个位置的“普通字符串”
    // width<0 表示左对齐,右边填空格
    // width>0 表示右对齐,左边填空格
    public static string StrFormat(string s, int width)
    {
      Encoding code = Encoding.Default;
      byte [] bs = code.GetBytes(s);
      bool leftAlign = (width < 0 ? true : false);
      if (width < 0) width = - width;
      if (bs.Length >= width) return s;
      if (leftAlign) return s.PadRight(width-bs.Length+s.Length);
      return s.PadLeft(width-bs.Length+s.Length);
    }