# Screwed Special Characters in an utf8 String Read From Database

**URL:** <https://www.ruby-forum.com/t/screwed-special-characters-in-an-utf8-string-read-from-database/121739>\
**Category:** Rails\
**Created:** [November 30, 2007, 1:37pm UTC](https://www.ruby-forum.com/t/screwed-special-characters-in-an-utf8-string-read-from-database/121739 "2007-11-30T13:37:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 30, 2007, 1:37pm UTC](https://www.ruby-forum.com/t/screwed-special-characters-in-an-utf8-string-read-from-database/121739/1 "2007-11-30T13:37:12Z")

</div>

Hello,  
I have a mysql database with a InnoDB table in utf8\_general\_ci  
encoding. Inside this table there is a column “path”, varchar(255),  
utf8\_general\_ci.

What I am trying to do now, is to use this path from the database to  
look up a local file and transmit this file to the user. The problem  
is, that my program is not able to open any files, that contain  
special characters (e.g. ÄÖÜ.txt) in their path (without special  
characters its fine). In these cases, the path-string seems to be  
screwed (if I print it to the console it is “Ã„Ã-ÃOE.txt”).

However, when I show the pathname inside the browser, or look at it in  
the database (phpmyadmin), the special characters seem to be correct.  
I already added the “encoding: utf8” line to my database.yml file, so  
this shouldnt be the problem.

Here is the code to send the file inside my controller:

def send\_document  
path = Document.find(params[:id]).path  
puts path # for “ÄÖÜ.txt” gives “Ã„Ã-ÃOE.txt” on console  
send\_file(path) # gives: Cannot read file ÄÖÜ.txt in browser  
end

Did anybody already have a similar problem or can give me some advice  
how to fix this?  
Thanks in advance, Erik Weitnauer.
