1 #include <stdio.h> 2 3 #include "export.hxx" 4 #include "utf8conv.hxx" 5 6 /*****************************************************************************/ 7 8 // MARKER(update_precomp.py): autogen include statement, do not remove 9 #include "precompiled_l10ntools.hxx" 10 #if defined(UNX) || defined(OS2) 11 int main( int argc, char *argv[] ) 12 #else 13 int _cdecl main( int argc, char *argv[] ) 14 #endif 15 /*****************************************************************************/ 16 { 17 if ( argc != 3 ) { 18 fprintf( stderr, "xgfconv InputFile OutputFile\n" ); 19 return ( 5 ); 20 } 21 22 ByteString sInput( argv[ 1 ] ); 23 ByteString sOutput( argv[ 2 ] ); 24 25 SvFileStream aInput( String( sInput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ ); 26 if ( !aInput.IsOpen()) { 27 fprintf( stderr, "ERROR: Unable to open input file!\n" ); 28 return ( 5 ); 29 } 30 31 SvFileStream aOutput( String( sOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC ); 32 if ( !aOutput.IsOpen()) { 33 fprintf( stderr, "ERROR: Unable to open output file!\n" ); 34 aInput.Close(); 35 return ( 5 ); 36 } 37 38 ByteString sLine; 39 sal_Bool bFirst = sal_True; 40 while ( !aInput.IsEof()) { 41 aInput.ReadLine( sLine ); 42 ByteString sLangId = sLine.GetToken( 0, '\t' ); 43 ByteString sFile = sLine.GetToken( 1, '\t' ); 44 ByteString sText = sLine.Copy( sLangId.Len() + sFile.Len() + 2 ); 45 46 sal_uInt16 nLangId = sLangId.ToInt32(); 47 CharSet aCharSet = Export::GetCharSet( nLangId ); 48 if ( aCharSet != 0xFFFF && sText.Len()) { 49 sText = UTF8Converter::ConvertToUTF8( sText, aCharSet ); 50 ByteString sOutput = sFile; 51 sOutput += "\t"; 52 sOutput += sText; 53 if ( !bFirst ) { 54 ByteString sEmpty; 55 aOutput.WriteLine( sEmpty ); 56 } 57 else 58 bFirst = sal_False; 59 aOutput.Write( sOutput.GetBuffer(), sOutput.Len()); 60 } 61 } 62 aInput.Close(); 63 aOutput.Close(); 64 return ( 0 ); 65 } 66 67