Posted to tcl by emiliano at Wed Jan 10 17:43:34 GMT 2024view raw
- namespace eval ::tcl::string::has {
- proc noncharacter {str} {
- regexp {[\ue000-\uf8ff\Uf0000-\UffffD\U100000-\U10fffd]} $str
- }
- namespace export -clear *
- namespace ensemble create -command ::tcl::string::has
- }
- namespace ensemble configure ::string -map \
- [dict merge \
- [namespace ensemble configure ::string -map] \
- [dict create has ::tcl::string::has]]
- # testing
- % string has noncharacter "hello world"
- 0
- % string has noncharacter "hello world\ue001"
- 1