Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/omega-rosetta/blob/main/drafts/rosettacode/string-length.wiki
# omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
branch `main` Branches Tags History
`omega-rosetta / drafts / rosettacode / string-length.wiki`
68 lines · 1312 bytes Raw Blame History
1 =={{header|Omegese}}==
2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}}
3 Omega has no imports, so the small output helpers (emit and friends) are part of the program.
4
5 om2
6 text nl "\n"
7 text tb " bytes "
8 text tc " characters\n"
9 text s1 "møøse"
10 text s2 "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
11 text s3 "J̲o̲s̲é̲"
12 note emit writes every byte of a to stdout; a short write is retried, an error exits 1
13 fn emit a view uchar * to void
14 o = ulong 0
15 while lt o len a bound 4096
16 k = write 1 a o sub len a o
17 if le k 0
18 exit 1
19 end
20 o = add o ulong k
21 end
22 end
23 note emitu writes n in decimal; 20 digits hold every ulong
24 fn emitu n ulong to void
25 d = new uchar 20 0
26 i = ulong 20
27 v = n
28 while true bound 20
29 i = sub i 1
30 put d i uchar add rem v 10 48
31 v = div v 10
32 if eq v 0
33 break
34 end
35 end
36 emit part d i sub 20 i
37 end
38 note a UTF-8 code point starts at every byte that is not a continuation byte 10xxxxxx
39 fn show a view uchar * to void
40 n = ulong 0
41 for i ulong len a
42 if ne and get a i 192 128
43 n = add n 1
44 end
45 end
46 emit a
47 emit nl
48 emitu len a
49 emit tb
50 emitu n
51 emit tc
52 end
53 fn main to int
54 show s1
55 show s2
56 show s3
57 ret 0
58 end
59
60 {{out}}
61
62 møøse
63 7 bytes 5 characters
64 𝔘𝔫𝔦𝔠𝔬𝔡𝔢
65 28 bytes 7 characters
66 J̲o̲s̲é̲
67 13 bytes 8 characters
68