Compare length of two strings

So... In what way does this task differ significantly from String lengtharrow-up-right? 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.

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;

Output:

Strings (πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦, πŸ€”πŸ‡ΊπŸ‡Έ, BOGUS!) sorted: "longest" first:
BOGUS!: characters:6,  Unicode code points:6,  UTF-8 bytes:6,  UTF-16 bytes:12
πŸ€”πŸ‡ΊπŸ‡Έ: characters:2,  Unicode code points:3,  UTF-8 bytes:12,  UTF-16 bytes:12
πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦: characters:1,  Unicode code points:7,  UTF-8 bytes:25,  UTF-16 bytes:22

Last updated

Was this helpful?