AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
``` //截取特定长度字符串,不够用...代替 public static string getStr2(string s, int l, string endStr) { string temp = s.Substring(0, (s.Length < l + 1) ? s.Length : l + 1); byte[] encodedBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(temp); string outputStr = ""; int count = 0; for (int i = 0; i < temp.Length; i++) { if ((int)encodedBytes[i] == 63) count += 2; else count += 1; if (count <= l - endStr.Length) outputStr += temp.Substring(i, 1); else if (count > l) break; } if (count <= l) { outputStr = temp; endStr = ""; } outputStr += endStr; return outputStr; } ```