#include <unistd.h>
#include <string.h>
#include <ctype.h>
+#include <errno.h>
#include <sys/param.h>
#include <sys/stat.h>
-#include <atalk/logger.h>
-#include <errno.h>
-
-#include <netatalk/endian.h>
-#include <atalk/unicode.h>
-
#ifdef HAVE_USABLE_ICONV
#include <iconv.h>
#endif
+
+#include <netatalk/endian.h>
+#include <atalk/unicode.h>
+#include <atalk/logger.h>
#include "byteorder.h"
0,
iconv_copy,
iconv_copy,
- CHARSET_WIDECHAR
+ CHARSET_WIDECHAR | CHARSET_PRECOMPOSED
};
struct charset_functions charset_ascii =
{
#ifdef HAVE_USABLE_ICONV
size_t ret = iconv((iconv_t)cd,
- inbuf, inbytesleft,
+ (ICONV_CONST char**)inbuf, inbytesleft,
outbuf, outbytesleft);
if (ret == (size_t)-1) iconv(cd, NULL, NULL, NULL, NULL);
return ret;
/* check if we can use iconv for this conversion */
#ifdef HAVE_USABLE_ICONV
- LOG (log_debug, logtype_default, "Trying %s/%s", UCS2ICONV, fromcode);
if (!ret->pull) {
ret->cd_pull = iconv_open(UCS2ICONV, fromcode);
if (ret->cd_pull != (iconv_t)-1)
ret->pull = sys_iconv;
}
- LOG (log_debug, logtype_default, "Trying %s/%s", tocode, UCS2ICONV);
if (!ret->push) {
ret->cd_push = iconv_open(tocode, UCS2ICONV);
if (ret->cd_push != (iconv_t)-1)
char **outbuf, size_t *outbytesleft)
{
ucs2_t curchar;
+
while (*inbytesleft >= 1 && *outbytesleft >= 2) {
if ((unsigned char)(*inbuf)[0] < 0x80) {
curchar = (ucs2_t) (*inbuf)[0];
- SSVAL((*outbuf),0,curchar);
+ SSVAL((*outbuf),0,curchar);
}
else {
errno = EILSEQ;