How do I force UTF-8 on an uploaded text file?

software development

#1

When I upload text files I get many strange characters. Like: │  ├──

Googling for answers it looks like a UTF-8 thing (could be wrong?) But I don’t know how to fix it or what to do. Is there a way to simply force UTF-8 for specific files? I tried adding “AddDefaultCharset UTF-8” to the .htaccess of the affected directory but it didn’t seem to change anything. Any ideas?

*I uploaded the text files to my domain hosted by Dreamhost using the FireFTP Firefox Add-on (with file transfer set to Automatic Mode, then again with ASCII Mode).


#2

Where are you seeing the characters? In the shell? Then you’ll need to set your locale settings. In your browser? Then you’ll need to set the http header for utf-8 (http://www.askapache.com/htaccess/setting-charset-in-htaccess.html)

Can you confirm that the file is being sent to the browser as utf-8?


#3

Twas in browser. As per your link I was able to fix by adding “AddCharset UTF-8 .txt” to the parent .htaccess file.

Spent an hour trying to figure that out before posting here! Thanks mate :wink: