Skip to content

Instantly share code, notes, and snippets.

@krmgns
Last active December 3, 2020 16:17
Show Gist options
  • Save krmgns/8009975 to your computer and use it in GitHub Desktop.
Save krmgns/8009975 to your computer and use it in GitHub Desktop.
PHP "ctype_print" for unicode (UTF-8)...
<?php
define("CTYPE_PRINT_UNICODE_PATTERN", "~^[\pL\pN\s\"\~". preg_quote("!#$%&'()*+,-./:;<=>?@[\]^_`{|}´") ."]+$~u");
function ctype_print_unicode($input) {
return preg_match(CTYPE_PRINT_UNICODE_PATTERN, $input);
}
print ctype_print_unicode("3 muços?"); // 1
@luckydonald
Copy link

Doesn't seem to work with

print ctype_print_unicode("¿3 muços?"); // 1

and characters like etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment