Issue #14077 has been updated by nirvdrum (Kevin Menard).


shevegen (Robert A. Heiler) wrote:

> > Even changing the $LANG environment variable within the Ruby
> > process doesn't seem to affect the value for these special
> > encodings.
> 
> You mean you used ENV['LANG']? Manipulating ENV works for me
> for other variables at the least such as CFLAGS and so forth.
> 
> Perhaps there may be a reason why there is no direct support,
> nobu may perhaps know more - they probably sleep right now in
> japan at 03:32 ... :)

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 `$LANG` 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 `$LANG` 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).



----------------------------------------
Feature #14077: Add Encoding::FILESYSTEM and Encoding::LOCALE constants
https://bugs.ruby-lang.org/issues/14077#change-67687

* Author: nirvdrum (Kevin Menard)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
The `Encoding` class has constants defined for all of the standard encodings, but does not have constants defined for some of the special encodings. In particular, the "filesystem" and "locale" encodings do not have a corresponding `Encoding::FILESYSTEM` and `Encoding::LOCALE`. As a result, every time they need to be used they must be looked up using `Encoding.find`. As far as I can tell, neither of these special encodings can change after the Ruby process has been started up. Even changing the `$LANG` environment variable within the Ruby process doesn't seem to affect the value for these special encodings.

Therefore, I'm proposing the introduction of `Encoding::FILESYSTEM` and `Encoding::LOCALE` constants both as a matter of consistency and as a matter of efficiency.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>