# Writing files in Windows in correct enc. for batch scripts

**URL:** <https://www.ruby-forum.com/t/writing-files-in-windows-in-correct-enc-for-batch-scripts/190465>\
**Category:** Ruby\
**Created:** [June 21, 2010, 2:50am UTC](https://www.ruby-forum.com/t/writing-files-in-windows-in-correct-enc-for-batch-scripts/190465 "2010-06-21T02:50:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweetpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@sweetpete](https://www.ruby-forum.com/u/sweetpete)\
**Post date:** [June 21, 2010, 2:50am UTC](https://www.ruby-forum.com/t/writing-files-in-windows-in-correct-enc-for-batch-scripts/190465/1 "2010-06-21T02:50:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sweetpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@sweetpete](https://www.ruby-forum.com/u/sweetpete)\
**Post date:** [June 21, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/writing-files-in-windows-in-correct-enc-for-batch-scripts/190465/2 "2010-06-21T18:22:45Z")

</div>

> 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](http://en.wikibooks.org/wiki/Ruby_Programming/Reference/Objects/Encoding)

has some helpful links at the bottom.
