SameShirtEveryDay.com

Personal blog of the one called Alex Gorbatchev, from Toronto, Canada.

Missing ‘a’ character on Windows with rspec and cucumber

Posted on April 18th, 2009 by Alex Gorbatchev. Tagged with , , , . In Rails, Ruby, Testing, Web Development. 10 comments!

cucumber_a_characters_missing

Trying to get a windows rails environment going this morning I stumbled upon something interesting – all ‘a’ characters were missing from cucumber and rspec output.

This has something to do with UTF-8 encoding and there’s a ticket and wiki post on cucumber about it, but no solution that I found acceptable.

Everything comes down to having change encoding in the current cmd window. This is achieved via a simple call to chcp 1252, but nobody want’s to do this every time, right?

To get this executed automaticaly and without resorting to serious registry editing, simply add this line to your cucmber.bat and any other batch files that are exhibiting this problem. You can find cucumber.bat in your /ruby/bin folder.

Here’s what it looks like:

chcp 1252
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "c:/ruby/bin/cucumber" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

10 comments.

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> , rel="nofollow" in use - no link dropping, no keywords or domains as names; do not spam, and do not advertise!

home
Subscribe to this blog Follow me on Twitter My bookmarks on Delicious My photography on Flickr