企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
~~~ getCharactersLen: function (charStr, cutCount) { if (charStr == null || charStr == '') return ''; var totalCount = 0; var newStr = ''; for (var i = 0; i < charStr.length; i++) { var c = charStr.charCodeAt(i); if (c < 255 && c > 0) { totalCount++; } else { totalCount += 2; } if (totalCount >= cutCount) { newStr += charStr.charAt(i); break; }else { newStr += charStr.charAt(i); } } return newStr; } ~~~