I am trying to create a text files with different sentences. I am using File.stuff methods to do that. How do I put a spacing (Simply like   in html and other lanuages)? I've been told I should use \b . It doesn't seem to work - I belive it's because I am writing in hebrew. What can I do?
Asked
Active
Viewed 864 times
1 Answers
3
I have no idea what File.stuff
is supposed to be - the File class has no such method.
If you want to use hebrew text in a ruby script, prepend the "magic encoding comment" to your file.
# encoding: UTF-8
hebrew = 'עברית'
-
I don't understand how to use that 'magic comment'.... Anyway- by file.stuff I meant I am using file methods (.write, .new etc.) – Ariel Mar 14 '11 at 18:29
-
Exactly as I wrote - just put the "# encoding" comment at the top of your ruby script and it'll parse fine with foreign charsets. When reading a file through File, you also need to be aware of the encoding of that file. See this question: [How to specify output file encoding in ruby](http://stackoverflow.com/questions/1378185/how-to-specify-output-file-encoding-in-ruby) – fx_ Mar 15 '11 at 14:07
-
In Ruby 2.0 and onwards, you can just use Hebrew literals in the source code. – Asaf Bartov Apr 03 '14 at 02:37
-
@AsafBartov if its ruby 1.8.7 if I have hebrew text in strings, and added in `# encoding: UTF-8`, will it display properly? I also set utf-8 in html with meta charset in application.html.haml. – Jngai1297 May 27 '14 at 21:06