[uclibc-ng-devel] [PATCH] towlower and locales

Eugene Yudin e.yudin at ndmsystems.com
Mon Jul 24 15:50:14 CEST 2017


Hi,

The function towlower doesn't work with locales diffrent from C.
Issue was introduced in this commit:
https://cgit.openadk.org/cgi/cgit/uclibc-ng.git/commit/?id=
8cde3a9bf2856dcb9a759dec7ecb04a68e712254
Call to setlocale is needed for correct generation of the table uplow_diff.
I received the compile time error "range assumption error" after
uncommenting the call.
Similar problem described here:
http://lists.uclibc.org/pipermail/uclibc/2015-March/048852.html

The attached patch fix the problem by using int32_t values.

Test program:
$ cat test.c
#include <locale.h>
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>

int main(int argc, char *argv[])
{
int i = 0;
wchar_t str[] = L"ТЕСТОВАЯ СТРОКА";
wchar_t c;

setlocale(LC_ALL, "ru_RU.utf-8");

wprintf(L"Input:\t\"%ls\"\n", str);
wprintf(L"Output:\t\"");

while (str[i]) {
c = str[i];
putwchar(towlower(c));
i++;
}

wprintf(L"\"\n");

return 0;
}

Output (without patch):
$ ./test
Input: "ТЕСТОВАЯ СТРОКА"
Output: "ТЕСТОВАЯ СТРОКА"

Output (with patch):
$ ./test
Input: "ТЕСТОВАЯ СТРОКА"
Output: "тестовая строка"

-- 
Best regards,
Eugene
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.uclibc-ng.org/pipermail/devel/attachments/20170724/0767d303/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uclibc_uplow_diff_use_int32.patch
Type: text/x-patch
Size: 4389 bytes
Desc: not available
URL: <http://mailman.uclibc-ng.org/pipermail/devel/attachments/20170724/0767d303/attachment.bin>


More information about the devel mailing list