buss
buss

Reputation: 100

TeamCity Rake Environment Variables Encoding::UndefinedConversionError: "\x84" from ASCII-8BIT to UTF-8

We're having issues with the character "ä" when output to a file in a rake build. It's being passed to rake as part of a string in a TeamCity environment variable. It's then output to a file with the following code:

output = File.new("#{path}", "w")
output.write("#{content}")
output.close

the character is output as "„". So we tried:

File.open("#{path}", "wt", encoding: 'UTF-8') do |f|
    f.puts "#{content}"
end

and this results in the error

Encoding::UndefinedConversionError: "\x84" from ASCII-8BIT to UTF-8

A suggestion elsewhere was to use force_encoding like this:

f.force_encoding("UTF-8")

but this results in no character being output at all.

We need the character to be output correctly.

Upvotes: 0

Views: 1421

Answers (1)

tyrizzle
tyrizzle

Reputation: 36

The only way that I found to get around this is to use html/xhtml codes.

The one for "ä" is ä. TeamCity renders the file with the ascii code, but it is read correctly when the file is opened.

See this page for a list of codes - you'll have to change them all in order for it to work: http://webdesign.about.com/library/bl_htmlcodes.htm

Upvotes: 2

Related Questions