1
Vote

Generated File has some deeper issues....

description

Ok i don't really know how best to describe what's going on here but let me try.
 
I'm generating a .sql file and then using ANT to change the USE [DBNAME] value (which i manually add at this point).
 
The problem is that when i try to do this target:
<target name="sql-edit-schema-file" description="generates the file which creates tables, views etc">
<replaceregexp file="DB/MS SQL ${db.server.version}/boomsocket_MSSQL_${db.server.version}.sql"
    match="\[[a-zA-Z0-1]{1,}\]"
    replace="[${db.name}]"
    flags="i" />
</target>
 
it keeps telling me that it can't find a match.
 
Now if i take the content of the generated file and put it into a new .sql file that i manually create and run the same ANT script it finds a match and process's as expected.
 
If I use TextPad to view the file and right click to view the "properties" the only difference i can see is that "file type" for the generated script is "unknown" and the "file type" for my manually created file says "PC". The other big difference is the SIZE of the file, the generated file is 1,951 KB and my file is 998 KB, this seems REALLY odd to me...
 
I've attached my manually created file so you can see the difference. I've noticed that EVERY generated file has the qualities mentioned above, regardless of the steps i take to create it.
 
I'm running this on a Windows XP Pro machine fully patched.
 
Eric

file attachments

comments

jonese wrote Feb 13, 2008 at 1:20 PM

i'm attached the generated file as well. Just In Case :)

Eric

wrote Feb 13, 2008 at 1:20 PM

jonese wrote Feb 14, 2008 at 1:29 PM

I've had a *nix buddy of mine look at the file as well. he says there are a lot of control characters embedded all over the place. I think what ever engine you are using to generate the file is doing a bit more then it really needs to.

jonese wrote Feb 14, 2008 at 2:01 PM

I'm attaching a screen shot of the generated file which shows all the control characters that are generated (all the little boxes for those who view this and don't know what I'm talking about). I use Eclipse to open this file and see the control characters, as you can see it appears that EVERY character is wrapped in some control character, which explains the issues I've had as well as the size of the files.

wrote Feb 14, 2008 at 2:01 PM

MToddSmith wrote Jul 15, 2008 at 7:21 PM

I threw together the following app to solve this problem. The problem you're running into is that the file is unicode.

Usage: WriteHeader.exe [database name] [input file] [output file]

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace WriteHeader
{
class Program
{
    static void Main (string[] args)
    {
        StreamReader input = new StreamReader (args[1], Encoding.Unicode);
        StreamWriter output = new StreamWriter (args[2], false, Encoding.Unicode);

        output.WriteLine ("use " + args[0]);
        output.WriteLine ("GO");
        output.WriteLine ("");

        string line = input.ReadLine ();
        while (line != null)
        {
            output.WriteLine (line);
            line = input.ReadLine ();
        }

        output.Flush ();
        input.Close ();
        output.Close ();
    }
}
}

wrote Feb 14, 2013 at 8:30 PM