;;;; A non-ASCII text that has crossed into a str still counts characters, ;;;; however many times it crosses; and a char is written through a dyn view of ;;;; typed storage as its code point where it fits. With an argument, \é ;;;; written into a view of bytes traps. (defn byte-len [s str] i32 (length s)) (defn main [args [str]] i32 (let [t (the dyn "é日😀")] (dotimes [i 3] (println (byte-len t))) (println (length t)) (println (at t 1)) (println (slice t 0 2))) (let [a (the [3 i32] [1 2 3]) v (the dyn a)] (set (at v 0) \z) (set (at v 1) \日) (println (at a 0) (at a 1) (at a 2))) (let [b (the [2 u8] [1 2]) w (the dyn b)] (set (at w 0) \a) (println (at b 0) (at b 1)) (when (> (length args) 1) (set (at w 1) \é))) 0)