UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

16 lines (15 loc) 586 B
import { getCtypePattern } from "../_helpers/_ctypePattern.js"; import { setlocale } from "../strings/setlocale.js"; export function ctype_print(text) { // discuss at: https://locutus.io/php/ctype_print/ // parity verified: PHP 8.3 // original by: Brett Zamir (https://brett-zamir.me) // example 1: ctype_print('AbC!#12') // returns 1: true if (typeof text !== 'string') { return false; } setlocale('LC_ALL', 0); const pattern = getCtypePattern('pr'); return pattern instanceof RegExp ? pattern.test(text) : false; }