开发者

Ruby on Rails Charset issue: Euro logo turns to €

开发者 https://www.devze.com 2023-01-27 13:54 出处:网络
I am using Ruby 1.8.7 and rails 2.3.5 Say for example in my controller I have this code: def test send_data \"€\", :type => \'text/plain;\',

I am using Ruby 1.8.7 and rails 2.3.5

Say for example in my controller I have this code:

def test
  send_data "€", :type => 'text/plain;',
                 :filename => 'test.txt'
end 

(the example is on mac) When the file is opened with TextMate, it shows Euro logo correctly, but when viewed by pressing "space" button or using TextEdit, that Euro logo shows as €

What should I do to make it show as Euro logo instead?

Any help would be much appreciated.

Thanks

HELP!!

UPDATE

I have made it work on my local version (Mac OSX machine) using:

Iconv.new('MacRoman', 'UTF-8').iconv(currency_code)

But on my public linux machine, it returns:

Iconv::InvalidEncoding (invalid encoding ("MacRoman", "UTF-8"))

I guess it has something to do with me having to install MacRoman encoding on my linux machine? How do I do that?

Update 2

I did not find the answer I expected, so we had to change TXT format to HTM开发者_C百科L, where you can specify its UTF-8.


TextEdit is using MacRoman to interpret the file instead of UTF-8. So, not your bug.


from http://reviews.cnet.com/8301-13727_7-10332226-263.html

Go to the menu named TextEdit. The second item is "Preferences." Select it. The window that opens has two tabs" "New Document" and "Open and Save." In each case, you can make changes to TextEdit's default settings.

Read more: http://reviews.cnet.com/8301-13727_7-10332226-263.html#ixzz172mnmbLl

0

精彩评论

暂无评论...
验证码 换一张
取 消