Как заставить работать wctomb?
Третий час ночи - может, оттого оно и не работает...
Почему такая штука:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char s[]="0123456789";
size_t r;
r=wctomb(s, 0x0424);
if (r != -1) {
printf("[%s]", s);
} else {
printf("error: %m\n");
}
return 0;
} // end func main;
упорно выводит:
error: Invalid or incomplete multibyte or wide character ?
По-моему, 0x0424 - вполне valid'ный wide character: буква Ф, если я правильно понимаю gucharmap.
В man wctomb написано, что "If wc can not be represented as a ultibyte sequence (according to the current locale), -1 is returned". Однако current locale вполне подходящая:
$ locale
LANG=ru_RU.utf8
LC_CTYPE="ru_RU.utf8"
LC_NUMERIC="ru_RU.utf8"
LC_TIME="ru_RU.utf8"
LC_COLLATE="ru_RU.utf8"
LC_MONETARY="ru_RU.utf8"
LC_MESSAGES="ru_RU.utf8"
LC_PAPER="ru_RU.utf8"
LC_NAME="ru_RU.utf8"
LC_ADDRESS="ru_RU.utf8"
LC_TELEPHONE="ru_RU.utf8"
LC_MEASUREMENT="ru_RU.utf8"
LC_IDENTIFICATION="ru_RU.utf8"
LC_ALL=