you are comparing individual characters in an utf-8 encoded string and not real unicode values.
I hacked something together to convert it properly, but it's untested.
PHP Code:
nameCheck(clientSlot) {
decl String:nameBuf[128];
if (GetClientName(clientSlot, nameBuf, sizeof(nameBuf))) {
new badcharcount=0;
for (new i=0; nameBuf[i]; i++) {
decl ucValue;
new cc = nameBuf[i];
if (cc & 1<<7) {
if (cc & 1<<6) { // 2|3|4 byte
if (cc & 1<<5) { // 3|4 byte
if (cc & 1<<4) { // 4 byte
ucValue = cc & (1<<3 - 1);
for (new n=0; n<3; n++) {
i++;
cc = nameBuf[i];
if ((cc & 192) == 128) {
ucValue = (ucValue<<6) | (cc & (1<<6 - 1));
} else {
LogError("invalid utf-8 sequence");
return;
}
}
} else { // 3 byte
ucValue = cc & (1<<4 - 1);
for (new n=0; n<2; n++) {
i++;
cc = nameBuf[i];
if ((cc & 192) == 128) {
ucValue = (ucValue<<6) | (cc & (1<<6 - 1));
} else {
LogError("invalid utf-8 sequence");
return;
}
}
}
} else { // 2 byte
ucValue = cc & (1<<5 - 1);
i++;
cc = nameBuf[i];
if ((cc & 192) == 128) {
ucValue = (ucValue<<6) | (cc & (1<<6 - 1));
} else {
LogError("invalid utf-8 sequence");
return;
}
}
} else {
LogError("invalid utf-8 sequence");
return;
}
} else {
ucValue = cc;
}
if (ucValue > s_characterThreshold) {
badcharcount++;
}
}
if (badcharcount > s_maxBadChars) {
PrintToServer("[Uninamer] renaming %s (bad chars: %d>%d)", nameBuf, badcharcount, s_maxBadChars);
LogMessage("renaming %s (bad chars: %d>%d)", nameBuf, badcharcount, s_maxBadChars);
GetConVarString(s_defaultName, nameBuf, 128);
ClientCommand(clientSlot, "name \"%s\"", nameBuf);
}
}
}