ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Solofnenko <>
Subject Re: removing byte order mark
Date Fri, 27 Jul 2007 17:36:42 GMT
For some reason I have had the same problem on Solaris, but not on 
Windows even though both JDK version and all jars were the same. At the 
end I wrote a <scriptdef> that would fix all XML files not to have BOM 
mark. It looks like that:

  <scriptdef name="fixbom" language="jython">
    <attribute name="dir" type="location"/>
    <attribute name="extensions" type="text"/>
import os
import fileutils
import utils
import pre


def getType(name):
  if idx<0: return name.lower()
  else: return name[idx:].lower()

def fixFiles(arg, dir_name, names):
  for name in names:
    if extensions.has_key(getType(name)):
      if len(content)>3 and content[0]==-17 and content[1]==-69 and 
        self.log("Removing BOM '"+path+"'...")
        fileutils.writeFileBin(path, content[3:])

os.path.walk(dir, fixFiles, None)

- Alexey.

Alex Egg wrote:
> A 3rd party ant task is getting the error, I'm sure it's not a problem
> with
> ant itself. This is the reason why I'd like to just remove the BOMs
> (they're
> not necessary) so I don't have to mess with the 3rd party tasks.
> Although, I wonder why the same task would run fine in OS X and not run
> in
> XP.... I have to look at it more I guess...
> Alex
> On 7/27/07, Steve Loughran <> wrote:
>> Alex Egg wrote:
>>> When I run my ant task from windows it gives me errors related to
> the
>>> unicode/utf8 byte order mark. I do not get this error when running
> the
>> same
>>> task from OS X.
>>> Anyways, what's an easy way to remove the BOM?
>>> Alex
>> This shouldnt happen; xerces should handle it. Can you post the build
>> file as an attachment, and the error message?
>> --
>> Steve Loughran        
>> Author: Ant in Action 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:

Alexey N. Solofnenko <>
Pleasant Hill, CA (GMT-8 usually)

View raw message