https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112017-11-03T17:11:19ZRuby Issue Tracking SystemRuby master - Feature #14077: Add Encoding::FILESYSTEM and Encoding::LOCALE constantshttps://redmine.ruby-lang.org/issues/14077?journal_id=676852017-11-03T17:11:19Zrrroybbbean (RRRoy BBBean)
<ul></ul><p>On Fri, 2017-11-03 at 16:35 +0000, <a href="mailto:ruby@kevin.nirvdrum.com" class="email">ruby@kevin.nirvdrum.com</a> wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Add Encoding::FILESYSTEM and Encoding::LOCALE constants (Open)" href="https://redmine.ruby-lang.org/issues/14077">#14077</a> has been reported by nirvdrum (Kevin Menard).<br>
Feature <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Add Encoding::FILESYSTEM and Encoding::LOCALE constants (Open)" href="https://redmine.ruby-lang.org/issues/14077">#14077</a>: Add Encoding::FILESYSTEM and Encoding::LOCALE<br>
constants<br>
<a href="https://bugs.ruby-lang.org/issues/14077" class="external">https://bugs.ruby-lang.org/issues/14077</a></p>
<ul>
<li>Author: nirvdrum (Kevin Menard)</li>
<li>Status: Open</li>
<li>Priority: Normal</li>
<li>Assignee: </li>
<li>Target version: <br>
...<br>
Therefore, I'm proposing the introduction of <code>Encoding::FILESYSTEM</code><br>
and <code>Encoding::LOCALE</code> constants both as a matter of consistency and<br>
as a matter of efficiency.<br>
This is a great idea. It makes Ruby programming easier and more<br>
intuitive. It's small innovations like this that have made Ruby into an<br>
awesome programming experience. Do more work in less time with less<br>
code.</li>
</ul>
</blockquote> Ruby master - Feature #14077: Add Encoding::FILESYSTEM and Encoding::LOCALE constantshttps://redmine.ruby-lang.org/issues/14077?journal_id=676862017-11-03T18:34:51Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>I am in agreement with the feature-suggestion. Not sure whether<br>
it should be a constant or a method or both but I agree that it<br>
may be useful to have direct support for this in ruby.</p>
<blockquote>
<p>Even changing the $LANG environment variable within the Ruby<br>
process doesn't seem to affect the value for these special<br>
encodings.</p>
</blockquote>
<p>You mean you used ENV['LANG']? Manipulating ENV works for me<br>
for other variables at the least such as CFLAGS and so forth.</p>
<p>Perhaps there may be a reason why there is no direct support,<br>
nobu may perhaps know more - they probably sleep right now in<br>
japan at 03:32 ... :)</p>
<p>rrroybbbean wrote:</p>
<blockquote>
<p>It's small innovations like this that have made Ruby into<br>
an awesome programming experience.</p>
</blockquote>
<p>Yes - please do not forget the documentation for it though!<br>
Since others rely on documentation.</p>
<p>Matz said several times that one (core?) part of ruby's philosophy<br>
is the "human aspect" aka how something is used with ruby. I think<br>
that this is also a reason why the ruby core team often likes<br>
to see "real world use cases" to determine how/if something is<br>
used.</p> Ruby master - Feature #14077: Add Encoding::FILESYSTEM and Encoding::LOCALE constantshttps://redmine.ruby-lang.org/issues/14077?journal_id=676872017-11-03T21:00:28Znirvdrum (Kevin Menard)
<ul></ul><p>shevegen (Robert A. Heiler) wrote:</p>
<blockquote>
<blockquote>
<p>Even changing the $LANG environment variable within the Ruby<br>
process doesn't seem to affect the value for these special<br>
encodings.</p>
</blockquote>
<p>You mean you used ENV['LANG']? Manipulating ENV works for me<br>
for other variables at the least such as CFLAGS and so forth.</p>
<p>Perhaps there may be a reason why there is no direct support,<br>
nobu may perhaps know more - they probably sleep right now in<br>
japan at 03:32 ... :)</p>
</blockquote>
<p>Sorry if I wasn't clear. Both of these encoding values are dependent on the system locale at the time the process is started. They're not not hard-coded into Ruby like UTF-8 or ASCII-8BIT. My point was that while altering <code>$LANG</code> before the process starts can affect the value of these special encodings, once the process is loaded the special encoding values never change, even if you change the <code>$LANG</code> value from within the process. I think what Ruby is doing is the preferable behavior. But, since the special encodings never change after process start up, I think there should be a faster way to reference them (e.g., a constant).</p> Ruby master - Feature #14077: Add Encoding::FILESYSTEM and Encoding::LOCALE constantshttps://redmine.ruby-lang.org/issues/14077?journal_id=676882017-11-03T21:31:41Zrrroybbbean (RRRoy BBBean)
<ul></ul><p>On Fri, 2017-11-03 at 18:34 +0000, <a href="mailto:shevegen@gmail.com" class="email">shevegen@gmail.com</a> wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Add Encoding::FILESYSTEM and Encoding::LOCALE constants (Open)" href="https://redmine.ruby-lang.org/issues/14077">#14077</a> has been updated by shevegen (Robert A. Heiler).<br>
I am in agreement with the feature-suggestion. Not sure whether<br>
it should be a constant or a method or both but I agree that it<br>
may be useful to have direct support for this in ruby.<br>
...<br>
Matz said several times that one (core?) part of ruby's philosophy<br>
is the "human aspect" aka how something is used with ruby. I think<br>
that this is also a reason why the ruby core team often likes<br>
to see "real world use cases" to determine how/if something is<br>
used.</p>
</blockquote>
<p>Many of my cheesy ruby scripts manipulate directory hierarchies on both<br>
windows and linux, often to fix problems that occur when you share an<br>
NTFS-formatted external disk drive between systems.</p>
<p>This is one of the most frequent things that I have to do, since many<br>
of my files (and some directories) use Korean UTF-8 characters:</p>
<p>Dir.entries('/.../mydir/',).each do |base|</p>
<p>I know that I must specify the encoding on Windows 7, or else it<br>
assumes Windows-1252 and messes up multi-byte characters. This code<br>
also works fine on Ubuntu 14, Fedora 24 and Debian 9, although I don't<br>
even know what the default or filesystem encoding is on Linux systems.</p>
<p>FYI, on Windows 7, I work exclusively with NTFS and Fat32. On Linux, I<br>
routinely work with EXT4, NTFS and Fat32. Are you aware that the NTFS<br>
driver for Linux allows you to create filesystem objects with names<br>
that are unworkable under Windows? [names with embedded colons : for<br>
instance]</p>
<p>I had to go to the Internet to figure out that I needed to use<br>
:encoding=>'UTF-8' to properly handle multi-byte characters on Windows<br>
7. It would have been nice to have Ruby tell me what the default<br>
encodings were. That's a lame reason for inclusion of this proposed<br>
feature, but it's all I have at the moment.</p>
<p>In the past, I ran into another problem, where I found embedded text of<br>
a character type different than the enclosing text. I find that even<br>
today, in filenames and text that mix English, Japanese and Korean<br>
texts into a single string or file. I blame word-processors for this<br>
mess. I used to jump through hoops to handle the problem, then I got<br>
smart and just forced the encoding to UTF-8, replacing bad characters<br>
with ''. In this situation, I don't see how knowing the filesystem or<br>
default encodings would help, since the person who created the<br>
Frankenstein-text didn't realize what they were doing.</p>