Removes non-printable ASCII characters.

Use String.replaceAll() with a regular expression to remove non-printable ASCII characters.

代码实现

String removeNonASCII(String str) {
  return str.replaceAll(RegExp(r'[^\x20-\x7E]'), '');
}

使用样例

removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum'