hasControlChars function
Unicode 的 Cc 类控制字符:U+0000~U+001F、U+007F~U+009F。
Implementation
bool hasControlChars(String text, {bool allowNewlines = false}) {
for (var i = 0; i < text.length; i++) {
final c = text.codeUnitAt(i);
if (c <= 0x1f) {
if (allowNewlines && (c == 0x0a || c == 0x0d || c == 0x09)) continue;
return true;
}
if (c >= 0x7f && c <= 0x9f) return true;
}
return false;
}