Compare length of two strings: Difference between revisions

m
→‎{{header|Raku}}: added emphasis
m (→‎{{header|Raku}}: added emphasis)
Line 14:
So... In what way does this task differ significantly from [[String length]]? Other than being horribly under specified?
 
In the modern world, string "length" is pretty much a useless measurement, especially in the absence of a specified encoding; hence Raku not even having an operator: "length" for strings.
 
<lang perl6>say 'Strings (👨‍👩‍👧‍👦, 🇺🇸🤔🇺🇸, BOGUS!) sorted: "longest" first:';
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}}
<pre>Strings (👨‍👩‍👧‍👦, 🇺🇸🤔🇺🇸, BOGUS!) sorted: "longest" first:
BOGUS!: characters:6, Unicode code points:6, UTF-8 bytes:6, UTF-16 bytes:12
👨‍👩‍👧‍👦🤔🇺🇸: characters:12, Unicode code points:73, UTF-8 bytes:2512, UTF-16 bytes:2212
🇺🇸👨‍👩‍👧‍👦: characters:1, Unicode code points:27, UTF-8 bytes:825, UTF-16 bytes:822</pre>
 
=={{header|Z80 Assembly}}==
10,333

edits