5 comments
Comment actions Permalink

Hello Bob,

Thank  you, it is a bug in documentation. I've filed an issue - http://youtrack.jetbrains.net/issue/RUBY-7572. The section was reorganized in first RubyMine versions. Encoding settings are available in Settings | General | IDE Encoding ("global" encoding) and in Status bar ("per file" encoding).

0
Comment actions Permalink

In Settings, I don't see General.

I have my project name highlighted (selected), in the Project window (the pane to the upper left) and I then click on the 'monkey wrench with the yellow spot' icon.

I see only Project Settings and IDE Settings sections. Nothing on the 1st or 2nd levels having to do with encodings.

----

I can see the UTF-8 on the status bar (lowest line on the IDE (RubyMine) window), but it is unclear whether this is a general indication, whether this will enforce the coding (!!) if changed, or what.

In particular, it doesn't change from UTF-8 no matter what file is selected in the Project window or shown in the editor window.

However, if I put the command:

puts __ENCODING__

In a source file (appropriately), when I issue a browser query ( http://localhost:3000/build_transactions/new ), that command prints out US-ASCII in the console log.

To make this command print out UTF-8, I must go to the *top* of that source file and add the line:

# coding: UTF-8

Then I get UTF-8 in the console log.  The UTF-8 in the status line does not change.

This is even though I have added the line -Dconsole.encoding=UTF-8 in /home/user1/Downloads/RubyMine-3.0.1/bin/rubymine.vmoptions

It is difficult to tell what causes what with encodings. (Aside - my UTF-8 encoding problems stem from iso8859-1 characters in a supposedly utf-8 input file)

Learning all the time..

0
Comment actions Permalink

Hi,

In Settings, I don't see General.

I have my project name highlighted (selected), in the Project window (the pane to the upper left) and I then click on the 'monkey wrench with the yellow spot' icon.

I see only Project Settings and IDE Settings sections. Nothing on the 1st or 2nd levels having to do with encodings

Screen shot 2011-01-13 at 12.58.45 PM.png

I can see the UTF-8 on the status bar (lowest line on the IDE (RubyMine) window), but it is unclear whether this is a general indication,

It is just encoding of current opened file. It means that RubyMine will save file in chosen encoding. By default it is "IDE Encoding".

In particular, it doesn't change from UTF-8 no matter what file is selected in the Project window or shown in the editor window.

Ok, it is reproducible on my machine too. I've noticed that if file is empty or contains only english characters RubyMine successfully changes UTF-8 to something else. Thanks, we will investigate it.


puts __ENCODING__

# coding: UTF-8 

File is just a sequence of bytes. And encoding is mapping between visible characters and their byte representation. I assume that Ruby 1.9 by default considers that file was saved in default system encoding and thus __ENCODING__ is ASCII. "#coding:..." option most likely tells ruby1.9 parser in which custom encoding the file should be read.

This is even though I have added the line -Dconsole.encoding=UTF-8 in /home/user1/Downloads/RubyMine-3.0.1/bin/rubymine.vmoptions
It is difficult to tell what causes what with encodings. (Aside - my UTF-8 encoding problems stem from iso8859-1 characters in a supposedly utf-8 input file)
Learning all the time..

-Dconsole.encoding option tells RubyMine in which encoding RubyMine should show process output. By default "IDE Encoding" is used.

0
Comment actions Permalink

OK, Settings | IDE Settings | General - I see it, ( Not --  Settings | General | IDE Settings  ) My brain search algorithm must be word order sensitive.

It might be handy if the RubyMine IDE could run something like the Linux/Unix command "file -bi" on the file shown in the editor window and then place the result in the status field where you now have UTF-8. This status would just be a read-only indicator of the encoding of the file in the editor window.

Ruby needs to know how to implement things like regular expressions and split(xxx). The generated code has to change depending on the encoding of the string being operated on (need to know input encoding precisely) and the strings in the regular expression source (this is the reason for the # coding: UTF-8 at the top of a source file. If you are looking for patterns containing umlauts, Ruby needs to know the encoding of the file to be searched and the encoding of the patterns before it can do much. Ruby 1.9 requires this information. Ruby 1.8 just muddled through..

An input file can be thought of as a collection of strings. Potentially, each string can have a different encoding. I haven't looked at the source code of "file -bi", so I don't know if it reads the whole file or just guesses based on reading a few lines. The worst case comes when Ruby has created a regular expression filter - looking for UTF-8 umlauts (a 2 byte encoding) and encounters an ISO-8859-1 umlaut (a 1 byte encoding) in the input file. It just throws an exception.

With Ruby 1.9, source file encoding and input file encodings are a big deal. The IDE needs to illuminate the potential problem as much as possible.

0
Comment actions Permalink

A good reference to Ruby encodings is The Tower of Babel Compatibility Kit (TBCK) http://nuclearsquid.com/talk/euruko.florian.gilcher.pdf

0

Please sign in to leave a comment.