
package gudusoft.gsqlparser.sql2xml.test;

import gudusoft.gsqlparser.EDbVendor;
import gudusoft.gsqlparser.sql2xml.generator.SQL2XMLGenerator;
import gudusoft.gsqlparser.sql2xml.generator.SQL2XMLGeneratorFactory;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class CodeGenerator
{

	public static void main( String[] args ) throws IOException
	{
		File testBaseDir = new File( "./testcases" );
		File[] testcases = testBaseDir.listFiles( );
		SQL2XMLGenerator generator = SQL2XMLGeneratorFactory.getGenerator( EDbVendor.dbvansi );
		for ( int i = 0; i < testcases.length; i++ )
		{
			File testcase = testcases[i];
			String caseName = testcase.getName( );
			if ( caseName.toLowerCase( ).endsWith( ".sql" ) )
			{
				String result = generator.generateXML( testcase );
				if ( result == null )
				{
					System.err.println( generator.getErrorMessage( ) );
				}
				else
				{
					int index = caseName.lastIndexOf( '.' );
					try
					{
						FileOutputStream fos = new FileOutputStream( new File( testBaseDir,
								caseName.substring( 0, index ) + ".xml" ) );
						fos.write( result.getBytes( ) );
						fos.close( );
					}
					catch ( Exception e )
					{
						e.printStackTrace( );
					}
				}
			}
		}
	}
}

@@ -300,16 +300,52 @@
 eption;%0D
+%0Aimport java.io.OutputStreamWriter;%0D
 %0A%0D%0Apubli
@@ -1188,19 +1188,106 @@
 %0D%0A%09%09%09%09%09%09
-fos
+OutputStreamWriter writer = new OutputStreamWriter( fos,%0D%0A%09%09%09%09%09%09%09%09%22UTF-8%22 );%0D%0A%09%09%09%09%09%09writer
 .write( 
@@ -1296,20 +1296,8 @@
 sult
-.getBytes( )
  );%0D
@@ -1303,19 +1303,22 @@
 %0D%0A%09%09%09%09%09%09
-fos
+writer
 .close( 

Support the utf-8 encoding.