Win32::API経由でStrCmpLogicalWを呼ぶメモ

# Written in UTF-8. Output is CP932.

use 5.16.0;
use strict;
use warnings;

use Encode qw/encode decode from_to/;
use Win32::API;

my $f = Win32::API::More->new('shlwapi', 'StrCmpLogicalW', 'PP', 'I');

my @strs = qw/
20string
2string
3string
st20ring
あいう
st2ring
st3ring
string2
ほげ
ほげほげ
string20
string3
/;

@strs = map  { from_to($_->[0], 'UTF-8', 'CP932'); $_->[0]; }
        sort { $f->Call($a->[1], $b->[1]) }
        map  { [$_, encode('UTF-16LE', decode('UTF-8', $_))] } @strs;

say for @strs;

StrCmpLogicalW function | Microsoft Docs