On Fri, Aug 11, 2023 at 7:29 AM Noah Misch <n...@leadboat.com> wrote:
> > The LCMapStringEx() solution is elegant. I do see > > https://learn.microsoft.com/en-us/windows/win32/intl/handling-sorting-in-your-applications > says, "If an application calls the function to create a sort key for a > string > containing an Arabic kashida, the function creates no sort key value." > That's > aggravating. > I think the problem there is that it is just poorly explained. Take for example the attached program that compares "normal" and "kashida" 'Raħīm' taken from [1], you'll get: c1 = c2 c2 = c1 meaning that "normal" and "kashida" are the same string. So, probably that phrase should read something like: "If an application calls the function to create a sort key for a string containing an Arabic kashida character, the function will ignore that character and no sort key value will be generated for it." [1] https://en.wikipedia.org/wiki/Kashida Regards, Juan José Santamaría Flecha
#include "windows.h" #include "stdio.h" static char comparison(int r) { switch (r) { case 1: return '>'; case -1: return '<'; case 0: return '='; default: return '!'; } } int wmain(int argc, wchar_t* argv[]) { const wchar_t *s1 = L"\u0631\u062d\u064a\u0645"; const wchar_t *s2 = L"\u0631\u062d\u0640\u0640\u0640\u0640\u0640\u0640\u064a\u0645"; int len; wchar_t c1[13]; wchar_t c2[13]; int result; len = LCMapStringEx(L"es-US", LCMAP_SORTKEY, s1, -1, c1, 13, NULL, NULL, 0); len = LCMapStringEx(L"es-US", LCMAP_SORTKEY, s2, -1, c2, 13, NULL, NULL, 0); result = memcmp(c1, c2, 13); printf("c1 %c c2\n", comparison(result)); result = memcmp(c2, c1, 13); printf("c2 %c c1\n", comparison(result)); return 0; }