localedef mishandles some multibyte locales
As Yao <firstname.lastname@example.org> noticed, there are two problems in localedef:
1) the type.c incorrectly assumes signed values for the wc which after conversion can actually be very large unsigned values (giving negative indices into certain arrays.)
2) wide.c miscounts strlen() leading to incorrect assumption of a truncated string.
This was detected while Yao was adding support for GB18030.