{"issue":{"state":"open","pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"milestone":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/9dc0b084716b31b98a0c81dbb3e3915d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"9dc0b084716b31b98a0c81dbb3e3915d","url":"https://api.github.com/users/Quintus","login":"Quintus","id":156358},"labels":[],"assignee":null,"updated_at":"2011-11-16T18:48:40Z","comments":4,"closed_at":null,"url":"https://api.github.com/repos/jnicklas/carrierwave/issues/514","body":"Hi there, \r\n\r\nI’m running a Rails 3.1 application and am getting an ArgumentError exception saying `invalid byte sequence in US-ASCII`. I’ve found this is caused by what I think is a bug in carrierwave. First, I’ve a Photo model like this: \r\n\r\n\tclass Photo < ActiveRecord::Base\r\n\t\tmount_uploader :image, ImageUploader\r\n\r\n\t\tvalidates :image, :presence => true\r\n\tend\r\n\r\nNow, when a user uploads a file with a name containing a non-ascii letter, the above error happens when evaluating `photo.image.url` (the uploading itself works just fine), because carrierwave assigns an US-ASCII encoding to the string where UTF-8 should be. Here’s a rails console session illustrating the problem: \r\n\r\n\tirb(main):005:0> photo.image\r\n\t=> /uploads/photo/image/110/CIMG1372ä.JPG\r\n\tirb(main):006:0> photo.image.url\r\n\t=> \"/uploads/photo/image/110/CIMG1372\\xC3\\xA4.JPG\"\r\n\tirb(main):007:0> photo.image.url.encoding\r\n\t=> #<Encoding:US-ASCII>\r\n\tirb(main):008:0> photo.image.url.force_encoding(\"UTF-8\")\r\n\t=> \"/uploads/photo/image/110/CIMG1372ä.JPG\"\r\n\r\nAs you can see, a workaround is to use String#force_encoding, but I doubt this is the regular usecase. \r\n\r\nSome information on my environment: \r\n\r\n`ruby -v`: `ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]`\r\n`rails -v`: `Rails 3.1.1`\r\n`gem -v`: `1.8.11`\r\ncarrierwave version: 0.5.7\r\ndatabase engine: sqlite3 (The application isn’t online yet, there I’ll be using postgres)\r\nOS: Arch Linux 64 bits\r\n\r\nValete,\r\nMarvin","html_url":"https://github.com/jnicklas/carrierwave/issues/514","title":"Filename with non-ascii letters causes encoding error","number":514,"id":2135155,"created_at":"2011-11-03T17:40:15Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/2bfdabe0aff4184ca7008c16ccf72e2a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"2bfdabe0aff4184ca7008c16ccf72e2a","url":"https://api.github.com/users/Salzig","login":"Salzig","id":99911},"updated_at":"2011-11-16T18:48:40Z","url":"https://api.github.com/repos/jnicklas/carrierwave/issues/comments/2765798","body":"And in a short test any of \"äöü\" is replaced with \"_\" within the filename. ","id":2765798,"created_at":"2011-11-16T18:48:40Z"}}