Writing files in Windows in correct enc. for batch scripts

P

Peter John

Hi,

Me again, ruby 1.9.1 and windows 7 x64.

My ruby program reads a ton of directory structures containing wav
files, tag metadata and cuesheets. It then goes on to generate (ruby
and/or batch) scripts that can be used to invoke lame (the mp3 encoder).
An example line from such a script would be:

ruby `lame --nohist -q0 -V0 -ms --vbr-new --id3v2-only
--replaygain-accurate --ta "10cc" --tl "Live In Concert - Volume One"
--ty "1995" --tn "01/08" --tc "EU1995" --tt "The Wall Street Shuffle"
"I:/media/Music/Archive/10cc/Live In Concert - EU1993 - Volume One/01
The Wall Street Shuffle.wav" "10cc/Live In Concert - EU1993 - Volume
One/01 The Wall Street Shuffle.mp3"`

If the input wav filename contains a French or German character, lame
fails saying that the input file does not exist. Seems that lame is not
getting the correct accent in the input parameters.

Adding # encoding: utf-8 doesn't help. Changing the batch file encoding
to windows-1252 when writing it from ruby causes EncodingConversion
errors in ruby - it breaks on the accented line, saying it cannot
convert utf-8 \xyz \xyz to windows-1252 (note that inside my ruby
program, I consistently work with utf-8).

It seems that in one case (utf-8) windows is misbehaving, and in the
other case (windows-1252) I cannot find a way to make ruby do what I
want.

Tips would be welcome.
 
R

Roger Pack

Adding # encoding: utf-8 doesn't help. Changing the batch file encoding
to windows-1252 when writing it from ruby causes EncodingConversion
errors in ruby - it breaks on the accented line, saying it cannot
convert utf-8 \xyz \xyz to windows-1252 (note that inside my ruby
program, I consistently work with utf-8).

do the batch files look "right"? Is this an issue with lame?
You might get some traction by experimenting with
Encoding.default_external Encoding.default_internal (basically by trying
to write the batch files by using some other encoding than the one you
currently are).

http://en.wikibooks.org/wiki/Ruby_Programming/Reference/Objects/Encoding

has some helpful links at the bottom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top