Posted to tcl by emiliano at Wed Jan 10 17:43:34 GMT 2024view raw

  1. namespace eval ::tcl::string::has {
  2. proc noncharacter {str} {
  3. regexp {[\ue000-\uf8ff\Uf0000-\UffffD\U100000-\U10fffd]} $str
  4. }
  5. namespace export -clear *
  6. namespace ensemble create -command ::tcl::string::has
  7. }
  8. namespace ensemble configure ::string -map \
  9. [dict merge \
  10. [namespace ensemble configure ::string -map] \
  11. [dict create has ::tcl::string::has]]
  12.  
  13. # testing
  14. % string has noncharacter "hello world"
  15. 0
  16. % string has noncharacter "hello world\ue001"
  17. 1
  18.