pere.noel
11/25/2006 10:11:00 AM
Paul Lutus <nospam@nosite.zzz> wrote:
> Sure. For mixed Windows and Unix/Linux line endings, just delete the
> carriage returns:
>
> data.gsub!{/\r/,"")
>
> >
<snip />
> Try this instead:
>
> data = File.read(filename)
>
> data.gsub!(/\r/,"")
>
> array = []
>
> data.split("\n").each do |line|
> # process lines here
> array << line
> end
>
> By using this approach, all your XML lines will be made uniform. At the end
> of the processing, you will need to reintegrate the lines into a block for
> storage:
>
> data = array.join("\n")
>
> file.open(filename,"w") { |f| f.write data }
OK fine thanks very much it's a nice solution somehow "normalizing" win*
line endings ;-)
In fact i've a little bit modified what u've wroten :
data.gsub!(/\r\n/,"\n")
data.gsub!(/\r/,"\n")
because i've discovered in the mean time i could have :
\r
\n
\r\n
lines endings )))
does \n\r exists ? (wikipedia says NO)
also because the most part of the audio input file is "binary" datas
there line ending is out of meaning, i suppose.
anyway, thanks a lot i'm now "armed" to face any situation ;-)
right now with the two first examples files i get doing my wav2xml and
reading the xml file gave me syntax colored results (within two
different text editors), then i think it is a proof the prob is cured !
--
une bévue