interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

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}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text nl "\n"
7text tb " bytes "
8text tc " characters\n"
9text s1 "møøse"
10text s2 "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
11text s3 "J̲o̲s̲é̲"
12note emit writes every byte of a to stdout; a short write is retried, an error exits 1
13fn emit a view uchar * to void
14o = ulong 0
15while lt o len a bound 4096
16k = write 1 a o sub len a o
17if le k 0
18exit 1
19end
20o = add o ulong k
21end
22end
23note emitu writes n in decimal; 20 digits hold every ulong
24fn emitu n ulong to void
25d = new uchar 20 0
26i = ulong 20
27v = n
28while true bound 20
29i = sub i 1
30put d i uchar add rem v 10 48
31v = div v 10
32if eq v 0
33break
34end
35end
36emit part d i sub 20 i
37end
38note a UTF-8 code point starts at every byte that is not a continuation byte 10xxxxxx
39fn show a view uchar * to void
40n = ulong 0
41for i ulong len a
42if ne and get a i 192 128
43n = add n 1
44end
45end
46emit a
47emit nl
48emitu len a
49emit tb
50emitu n
51emit tc
52end
53fn main to int
54show s1
55show s2
56show s3
57ret 0
58end
59</syntaxhighlight>
60{{out}}
61<pre>
62møøse
637 bytes 5 characters
64𝔘𝔫𝔦𝔠𝔬𝔡𝔢
6528 bytes 7 characters
66J̲o̲s̲é̲
6713 bytes 8 characters
68</pre>