Encoding::UndefinedConversionError when file name has non-standard characters

226 views
Skip to first unread message

Przemek M.

unread,
Oct 17, 2010, 10:30:10 AM10/17/10
to Dragonfly
Using dragonfly (0.7.6), Rails (3.0.1), Ruby (1.9.2) I have the
following error:

Encoding::UndefinedConversionError in UsersController#create
"\xC4" from ASCII-8BIT to UTF-8

This error occurs when I try to upload an image that has some non-
standard characters in filename (I mean Polish chars like: ąśźłó).
What can I do to avoid this error? Could I overwrite somehow the
original filename before it is being processed by Dragonfly?
Or perhaps there is some other solution?

Przemek M.

unread,
Oct 17, 2010, 2:56:28 PM10/17/10
to Dragonfly
As the error seems to be related with Rails itself, my question would
be now: how can I validate the name of the file to not contain
problematic characters?

zoopzoop

unread,
Oct 27, 2010, 6:51:30 AM10/27/10
to Dragonfly
Przemek, check out ActiveSupport's transliterate to replace non-ASCII
characters.
http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-transliterate
Reply all
Reply to author
Forward
0 new messages