On 12/14/2016 05:45 PM, Lauri Kenttä wrote:
On 2016-12-14 12:23, Henri Verbeet wrote:
On 13 December 2016 at 19:48, Lauri Kenttä <lauri.kentta(a)gmail.com> wrote:
@@ -2027,6 +2027,19 @@ static int wctoint(WCHAR c, int base) v = c - 'A' + 10; else if ('a' <= c && c <= 'z') v = c - 'a' + 10; + else { + /* Unicode points that contain digits 0-9; keep this sorted! */ + static const WCHAR zeros[] = { + 0x660, 0x6f0, 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6, + 0xd66, 0xe50, 0xed0, 0x1040, 0x17e0, 0x1810, 0xff10 + }; + int i; + for (i = 0; i < sizeof(zeros)/sizeof(zeros[0]) && c >= zeros[i]; ++i) { + if (zeros[i] <= c && c < zeros[i] + base) { Using "base" here seems questionable. That would imply that e.g. with base 16, "\x6f2\x6fa"/"۲ۺ" would return "42". Is that really the case?
My bad, I've "optimized out" the missing c < zeros[i] + 10.
For what it's worth, note also that Wine has wine_fold_string(), which should be consistent with FoldString().
I don't see what FoldString could do here. MAP_FOLDDIGITS looks relevant to what you're doing.