Compare length of two 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:22Last updated