RosettaCodeData/Task/Substring-Top-and-tail/OmniMark/substring-top-and-tail-2.xom
2024-10-16 18:07:41 -07:00

35 lines
1.1 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

include "utf8pat.xin"
define stream function ucps (value stream chars) as
local integer num
local stream unicodes
open unicodes as buffer
repeat scan chars
match utf8-char => s-char
set num to utf8-char-number(s-char)
put unicodes 'U+%u16r4fzd(num) '
again
close unicodes
return unicodes
process
local stream s variable initial {'brooms', '𝓱𝓲𝓽', 'là'}
repeat over s
output '----------------------------------------------------------------%n'
output 'Word: %g(s)%n ' || ucps(s) || '%n'
do scan s
match utf8-char utf8-char+ => firstremoved
output 'First removed: %x(firstremoved)%n '
output ucps(firstremoved) || '%n'
done
do scan s
match ((lookahead not (utf8-char value-end)) any)+ => lastremoved
output 'Last removed: %x(lastremoved)%n '
output ucps(lastremoved) || '%n'
done
do scan s
match utf8-char ((lookahead not (utf8-char value-end)) any)+ => bothremoved
output 'Both removed: %x(bothremoved)%n '
output ucps(bothremoved) || '%n'
done
again