Closed kalashnikovisme closed 5 years ago
I've solved this problem by adding _forceencoding method
Settings.defaults['foo'].force_encoding('UTF-8')
This is not best practice. Can anyone offer better solution?
You either put
encoding: utf-8
at the beginning of your files, Or set the encoding in your text editor - it varies by editor, but I've had the most success with "UTF8 no Byte Order Marking"
@Sudrien but what is "UTF8 no Byte Order Marking"?
@kalashnikovisme - sorry, I got the name slightly wrong; It's just "Byte Order Mark", or BOM for short.
The long version is http://unicode.org/faq/utf_bom.html
The short version: Some versions of Unicode allow bytes to be ordered differently - most significant byte first, least significant byte first. "Big Endian" and "Little Endian" are alternate names. These versions have a Byte Order Mark at the beginning of the file to say which variation of Unicode is being used.
UTF8 can have this mark, but does not have to. In fact, the mark can confuse some interpreters. So if your text editor has a URF8 encoding option, say yes to that, but if it has further options to use BOM, I'd recommend saying no to that option.
I have error:
Rails -v 4.1.7 Ruby 2.1.2p95
Any idea?