[gnuwin32 - Help] RE: libiconv unresolved external

"SourceForge.net" <[email protected]>
Newsgroups gmane.comp.windows.gnu.user
Message-ID <[email protected]>
Read and respond to this message at: 
https://sourceforge.net/forum/message.php?msg_id=4845616
By: magusxion

win_iconv compiled in fine, thanks for suggesting it.  I was wondering if there
are any examples that you may know of that I can look over.  I am having some
difficulty getting it to convert from ISO-8859-1 to UTF-8, it doesn't return
the error code it just returns 0.  It may just be the input ( garbage in, garbage
out ), but some examples would help me to understand if I'm incorrectly using
the functions.

This is my current code:

bool convertToUTF8( std::string src, std::string out, std::string
srcEnc="windows-1252" )
{

FILE* inputText = fopen( src.c_str(), "rb" );
fseek( inputText, 0, SEEK_END );
long fileSize = ftell( inputText );
fseek( inputText, 0, SEEK_SET );

char* inFileBuf = new char[fileSize+1];
long bytes_read = fread( (void*)inFileBuf, sizeof(char), fileSize, inputText );
fclose( inputText );

if( bytes_read != fileSize )
     return false;

inFileBuf[fileSize] = '\0';
char*  outFileBuf = new char[fileSize+1];
	
iconv_t cd;
cd = iconv_open( "UTF-8", srcEnc.c_str() );
unsigned int iconvResult = iconv( cd, (const char**)&inFileBuf, (unsigned
int*)&fileSize, &outFileBuf, (unsigned int*)&fileSize );

iconv_close( cd );
	
if( iconvResult != sizeof(-1) && iconvResult != 0 )
{
	FILE* outFile = _wfopen( (wchar_t*)out.c_str(), L"wb" );
	fwrite( (void*)outFileBuf, sizeof(wchar_t), fileSize, outFile );
	fclose( outFile );
	return true;
}

return false;

}

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit: 
https://sourceforge.net/forum/unmonitor.php?forum_id=74807

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.