# Rails, 1.9 & Encoding - does it work?

**URL:** <https://www.ruby-forum.com/t/rails-1-9-encoding-does-it-work/185391>\
**Category:** Rails\
**Created:** [March 19, 2010, 5:38am UTC](https://www.ruby-forum.com/t/rails-1-9-encoding-does-it-work/185391 "2010-03-19T05:38:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![donncha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/90db22/32.png) [@donncha](https://www.ruby-forum.com/u/donncha)\
**Post date:** [March 19, 2010, 5:38am UTC](https://www.ruby-forum.com/t/rails-1-9-encoding-does-it-work/185391/1 "2010-03-19T05:38:41Z")

</div>

Hey all,

I’ve been looking into moving our Rails app to 1.9 and am having lots of  
trouble with string encodings, especially when it comes to file uploads.

We allow users to upload text files, which may, or may not, have  
accented characters in them. If there are accented characters, we insist  
that the file is UTF-8, but if there are no accented characters we don’t  
care what encoding the file is.

It seems that w/ Rails 2.3.5 ALL files upload as ASCII-8BIT, regardless  
of OS $LANG setting, or actual file encoding.  
params[:file].external\_encoding also appears to be ASCII-8BIT as well,  
so I can’t use content.encode(“utf-8”, xxx) because I’ve no idea what  
the file is _supposed_ to be encoded as.

Since I’m on OSX and $LANG == en\_AU.UTF-8, shouldn’t all files default  
to UTF-8 unless explicitly told otherwise?

Has anyone got 2.3.5 working well w/ 1.9 when accented characters are  
involved?

Any tips?

thanks,  
donncha
