Browse files

Try to fix utf-8 to utf-16 bug

  • Loading branch information...
1 parent 6ff56da commit 048fc6be972189e62ca3b9453d19233ec5773016 @alanjds committed with Avelar Oct 1, 2012
View
2 lib/exception_notifier/views/exception_notifier/background_exception_notification.html.erb
@@ -18,7 +18,7 @@
"#{title}\n\n#{summary.gsub(/^/, " ")}\n\n"
end
end.join
- sections = sections.force_encoding('UTF-8').encode('UTF-16', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
+ sections = sections.force_encoding('UTF-8').encode('UTF-16LE', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
%>
<%= raw sections %>
</pre>
View
2 lib/exception_notifier/views/exception_notifier/background_exception_notification.text.erb
@@ -10,6 +10,6 @@
"#{title}\n\n#{summary.gsub(/^/, " ")}\n\n"
end
end.join
- sections = sections.force_encoding('UTF-8').encode('UTF-16', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
+ sections = sections.force_encoding('UTF-8').encode('UTF-16LE', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
%>
<%= raw sections %>
View
2 lib/exception_notifier/views/exception_notifier/exception_notification.html.erb
@@ -27,7 +27,7 @@
[title, summary.gsub(/^/, " "), nil].join("\n\n")
end
end.join
- sections = sections.force_encoding('UTF-8').encode('UTF-16', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
+ sections = sections.force_encoding('UTF-8').encode('UTF-16LE', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
%>
<%= raw sections %>
View
2 lib/exception_notifier/views/exception_notifier/exception_notification.text.erb
@@ -19,7 +19,7 @@
[title, summary.gsub(/^/, " "), nil].join("\n\n")
end
end.join
- sections = sections.force_encoding('UTF-8').encode('UTF-16', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
+ sections = sections.force_encoding('UTF-8').encode('UTF-16LE', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
%>
<%= raw sections %>

2 comments on commit 048fc6b

@dsilver829

I'm getting a UTF-8 to UTF-16 conversion error since upgrading to exception_notification v3.0.0. Is this the fix for that? A fix would be awesome.

@alanjds
Owner

Well, its MY fix to UTF-8 to UTF-16 bug. I read somewhere that ruby distinguishes the processor family, so UTF-16 Little Endian and Big Endian.

My fix have no tests and I am sure that it will not work on some architectures supported by ruby, so I made no pull request to the main branch. Feel free to use and improve it :)

Please sign in to comment.