Compare length of two strings: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: add another encoding for comparison)
m (→‎{{header|Raku}}: more accurate terminology)
Line 17: Line 17:


<lang perl6>say 'Strings (👨‍👩‍👧‍👦, 🇺🇸, BOGUS!) sorted: "longest" first:';
<lang perl6>say 'Strings (👨‍👩‍👧‍👦, 🇺🇸, BOGUS!) sorted: "longest" first:';
say "$_: characters:{.chars}, UTF-8 code points:{.codes}, UTF-8 bytes:{.encode('UTF8').bytes}, UTF-16 bytes:{.encode('UTF16').bytes}" for <👨‍👩‍👧‍👦 BOGUS! 🇺🇸>.sort: -*.chars;</lang>
say "$_: characters:{.chars}, Unicode code points:{.codes}, UTF-8 bytes:{.encode('UTF8').bytes}, UTF-16 bytes:{.encode('UTF16').bytes}" for <👨‍👩‍👧‍👦 BOGUS! 🇺🇸>.sort: -*.chars;</lang>
{{out}}
{{out}}
<pre>Strings (👨‍👩‍👧‍👦, 🇺🇸, BOGUS!) sorted: "longest" first:
<pre>Strings (👨‍👩‍👧‍👦, 🇺🇸, BOGUS!) sorted: "longest" first:
BOGUS!: characters:6, UTF-8 code points:6, UTF-8 bytes:6, UTF-16 bytes:12
BOGUS!: characters:6, Unicode code points:6, UTF-8 bytes:6, UTF-16 bytes:12
👨‍👩‍👧‍👦: characters:1, UTF-8 code points:7, UTF-8 bytes:25, UTF-16 bytes:22
👨‍👩‍👧‍👦: characters:1, Unicode code points:7, UTF-8 bytes:25, UTF-16 bytes:22
🇺🇸: characters:1, UTF-8 code points:2, UTF-8 bytes:8, UTF-16 bytes:8</pre>
🇺🇸: characters:1, Unicode code points:2, UTF-8 bytes:8, UTF-16 bytes:8</pre>


=={{header|Z80 Assembly}}==
=={{header|Z80 Assembly}}==