| removing byte order mark | removing byte order mark 2007-07-27 - By Alex Egg
Cool, I'll try this out.
On 7/27/07, Alexey Solofnenko <A.Solofnenko@(protected)> wrote: > > 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"/> > <![CDATA[ > #fixbom > import os > import fileutils > import utils > import pre > > dir=str(attributes.get("dir")) > extensions=utils.makeSet(str(attributes.get("extensions"))) > > def getType(name): > idx=name.rfind('.') > 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)): > path=dir_name+os.sep+name > content=fileutils.readFileBin(path) > if len(content)>3 and content[0]==-17 and content[1]==-69 and > content[2]==-65: > self.log("Removing BOM '"+path+"'...") > fileutils.writeFileBin(path, content[3:]) > > os.path.walk(dir, fixFiles, None) > ]]> > </scriptdef> > > > - 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 <stevel@(protected)> 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 http://www.1060.org/blogxter/publish/5 > >> Author: Ant in Action http://antbook.org/ > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscribe@(protected) > >> For additional commands, e-mail: user-help@(protected) > >> > >> > >> > > > > > > -- > ------------------------------------------------------------------------ > Alexey N. Solofnenko <http://trelony.cjb.net/> > Pleasant Hill, CA (GMT-8 usually) > >
|
|
 |