示例#1
0
 public static string TrimBytes(this string input, int maxLength)
 {
     return(new string(input
                       .TakeWhile((c, i) =>
                                  ShiftJIS.GetByteCount(input.Substring(0, i + 1)) <= maxLength)
                       .ToArray()));
 }