summaryrefslogtreecommitdiff
path: root/transex3/source/xgfconv.cxx
blob: 2d1eb0140203a69bd8e4ebddd2b0f3d756d3129a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>

#include "export.hxx"
#include "utf8conv.hxx"

/*****************************************************************************/
#if defined( UNX ) || defined( MAC )
int main( int argc, char *argv[] )
#else
int _cdecl main( int argc, char *argv[] )
#endif
/*****************************************************************************/
{
    if ( argc != 2 ) {
        fprintf( stderr, "xgfconv InputFile\n" );
        return ( 5 );
    }

    ByteString sInput( argv[ 1 ] );

    SvFileStream aInput( String( sInput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ );
    if ( !aInput.IsOpen())
        return ( 5 );

    ByteString sLine;
    while ( !aInput.IsEof()) {
        aInput.ReadLine( sLine );
        ByteString sLangId = sLine.GetToken( 0, '\t' );
        ByteString sFile = sLine.GetToken( 1, '\t' );
        ByteString sText = sLine.Copy( sLangId.Len() + sFile.Len() + 2 );

        USHORT nLangId = sLangId.ToInt32();
        CharSet aCharSet = Export::GetCharSet( nLangId );
        if ( aCharSet != 0xFFFF ) {
            sText = UTF8Converter::ConvertToUTF8( sText, aCharSet );
            fprintf( stdout, "%s\t%s\n", sFile.GetBuffer(), sText.GetBuffer());
        }
    }
    aInput.Close();
    return ( 0 );
}