b348
![]() |
|
|
|
|
|||||||
| Porting New Software Having trouble or general questions about porting software to FreeBSD? Ask here. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
Hi all,
Working on a C project that uses iconv, it works properly on Fedora and Windows yet fails on FreeBSD-8.2. Hoping someone can point me in the direction of a resolution. The errno is 86, And is defined in /usr/local/include/iconv.h as: Code:
EILSEQ 86 /* Illegal byte sequence */ With the following info one would think it would work on FreeBSD and Win32, but not Fedora. Systems info: Code:
FreeBSD 8.2 #iconv --version iconv (GNU libiconv 1.14) Copyright (C) 2000-2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Bruno Haible. Code:
WinXPsp3/Win7 C:\>iconv --version iconv (GNU libiconv 1.14) Copyright (C) 2000-2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Bruno Haible. GNU libiconv v1.14 Code:
Fedora v?? (copy and paste from another users email) #iconv --version iconv (GNU libc) 2.15 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Ulrich Drepper. Code:
char mb[8];
char *outbuf = mb;
size_t inlen = sizeof(wchar_t)/sizeof(char);
size_t outlen = 8
wchar_t &wc = THIS->operator[](i);
const char *inbuf = (const char *)&wc;
codec = iconv_open("UTF-8", "WCHAR_T");
iconv(codec, NULL, NULL, NULL, NULL);
if(iconv(codec, &inbuf, &inlen, &outbuf, &outlen) == -1)
Code:
(gdb) x inbuf 0x28ee2d10: 0x00007684 Thanks y'all. -Enjoy fh : )_~ |
|
#2
|
||||
|
||||
|
Simple test program.
Code:
#include <stdio.h>
#include <iconv.h>
// FreeBSD
// g++ -g -o iconv-test -I/usr/local/include -L/usr/local/lib iconv-test.cpp -liconv
// On Win32 I use MinGW32, I use Strawberry Perl so I use it's MinGW ...
// g++ -g -o iconv-test -IC:/Strawberry/c/include -LC:/Strawberry/c/lib iconv-test.cpp -liconv
#if defined(__FreeBSD__)
size_t iconv_wrap(iconv_t cd, char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
{
char *in = *inbuf;
const char *in_c = (const char*)(in);
return iconv(cd, &in_c, inbytesleft, outbuf, outbytesleft);
}
#else
size_t iconv_wrap(iconv_t cd, char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
{
return iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft);
}
#endif /* __FreeBSD__ */
int main(int argc, char* argv[])
{
iconv_t codec;
char mb[8];
char *inbuf, *outbuf;
size_t inlen, outlen;
outlen = 8;
outbuf = mb;
inlen = sizeof(wchar_t)/sizeof(char);
const wchar_t &wc = 30340;
inbuf = (char *)&wc;
codec = iconv_open("UTF-8", "WCHAR_T");
if(!codec)
printf("iconv_open failed.\n");
iconv(codec, NULL, NULL, NULL, NULL);
if(iconv_wrap(codec, &inbuf, &inlen, &outbuf, &outlen) == -1) {
printf("iconv failed.\n");
iconv_close(codec);
return -1;
}
iconv_close(codec);
mb[8-outlen] = '\0';
for(int i = 0; i<8-outlen; i++)
printf(":%x:", mb[i]);
return 0;
}
fh : )_~ |
|
#3
|
||||
|
||||
|
WCHAR_T is system dependent!
Use the encoding that created the String that the wchar_t &wc came from in the first place ... Duh! However, I didn't know what that was, this is software written by ??? I do not understand all this utf / Unicode / Code sets / Wide Char / etc ... Just trying to fix something that's broke! Yup, I know I need to do some serious educating on this topic, I know a bunch more today then I did 5 days ago! If I would of just kept at it another two hours I wouldn't be wasting y'alls time. Input is still welcome. -Enjoy fh : )_~ |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FreeBSD 9.0 & PHP (5 - 5.5) iconv error | andisian | Installation and Maintenance of FreeBSD Ports or Packages | 14 | December 28th, 2012 18:32 |
| Replace unzip with unzip-iconv | wasabi | Installation and Maintenance of FreeBSD Ports or Packages | 1 | March 5th, 2012 16:27 |
| [Solved] Iconv with ruby19 | migbsd | Installation and Maintenance of FreeBSD Ports or Packages | 4 | June 23rd, 2010 02:07 |
| remove iconv lib dependency from Libxml2 | ayeshagutpa | Installation and Maintenance of FreeBSD Ports or Packages | 0 | April 22nd, 2010 09:53 |
| freebsd 7.0- Error Mounting /dev/acd0 on /dist: Input/output error (5) | Lego | Installing & Upgrading | 52 | November 30th, 2008 16:31 |