I searched for a long time, found nothing (nice code). Based on the experience, it reached regular expressions.
The task can be put on, I want to have only the necessary symbols in the string:
Below is a template (not fully working code) from a working project (Delphi 10.4)
uses
System.regularexpressions;
Function UpdateinFormorder (IDORDER: String): Integer;
Var
TEMP, Strregexp: String;
REGEX: TREGEX;
Begin
regex.create ('');
// What is allowed in the string utf English, Russian Code page, number and other
strregexp: = '[^A-Za-zА-Яа-я0-9 _ ,, ..?!-@<> "; ::; ()+=/\ |]';
// in TEMP we keep the string cut from extra characters
TEMP: = regex.Replace ('testing 😀', strregexp, '');
end;