add utf-8 check, substitution, and warning to Input::parse() function

This commit is contained in:
Axel Kohlmeyer
2021-01-25 20:53:59 -05:00
parent 69e7480fed
commit a119164496
2 changed files with 12 additions and 0 deletions

View File

@ -106,6 +106,7 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp)
label_active = 0;
labelstr = nullptr;
jump_skip = 0;
utf8_warn = true;
if (me == 0) {
nfile = 1;
@ -421,6 +422,16 @@ void Input::parse()
ptr++;
}
if (utils::has_utf8(copy)) {
std::string buf = utils::utf8_subst(copy);
strcpy(copy,buf.c_str());
if (utf8_warn && (comm->me == 0))
error->warning(FLERR,"Detected non-ASCII characters in input. "
"Will try to continue by replacing with ASCII "
"equivalents where known.");
utf8_warn = false;
}
// perform $ variable substitution (print changes)
// except if searching for a label since earlier variable may not be defined

View File

@ -54,6 +54,7 @@ class Input : protected Pointers {
int label_active; // 0 = no label, 1 = looking for label
char *labelstr; // label string being looked for
int jump_skip; // 1 if skipping next jump, 0 otherwise
bool utf8_warn; // true if need to warn about UTF-8 chars
FILE **infiles; // list of open input files