Permalink
Browse files

Switched back to more standard 'UTF-8' econding

  • Loading branch information...
mocoso committed Feb 13, 2009
1 parent 735086d commit eb15b10a000310157c3e338e84f6e740d7448e3f
Showing with 11 additions and 7 deletions.
  1. +2 −2 README
  2. +9 −5 lib/csv_builder.rb
View
4 README
@@ -36,9 +36,9 @@ e.g.
You can also set the input encoding and output encoding by setting
<tt>@input_encoding</tt> and <tt>@output_encoding</tt> instance variables.
-These default to 'UTF8' and 'LATIN1' respectively. e.g.
+These default to 'UTF-8' and 'LATIN1' respectively. e.g.
- @output_encoding = 'UTF8'
+ @output_encoding = 'UTF-8'
You can also attach a csv file to mail sent out by your application by
including a snippet like the following in your mailer method
View
@@ -21,9 +21,9 @@ module TemplateHandlers
#
# You can also set the input encoding and output encoding by setting
# <tt>@input_encoding</tt> and <tt>@output_encoding</tt> instance variables.
- # These default to 'UTF8' and 'LATIN1' respectively. e.g.
+ # These default to 'UTF-8' and 'LATIN1' respectively. e.g.
#
- # @output_encoding = 'UTF8'
+ # @output_encoding = 'UTF-8'
class CsvBuilder < TemplateHandler
@@ -49,14 +49,18 @@ def compile(template)
# Transliterate into the required encoding if necessary
# TODO: make defaults configurable
- @input_encoding ||= 'UTF8'
+ @input_encoding ||= 'UTF-8'
@output_encoding ||= 'LATIN1'
if @input_encoding == @output_encoding
result
else
- # TODO: do some checking to make sure iconv works correctly in current environment
- # See ActiveSupport::Inflector#transliterate definition for details
+ # TODO: do some checking to make sure iconv works correctly in
+ # current environment. See ActiveSupport::Inflector#transliterate
+ # definition for details
+ #
+ # Not using the more standard //IGNORE//TRANLIST because it raises
+ # Iconv::IllegalSequence for some inputs
c = Iconv.new("\#{@output_encoding}//TRANSLIT//IGNORE", @input_encoding)
c.iconv(result)
end

0 comments on commit eb15b10

Please sign in to comment.