Issue #4854 has been reported by Rafal Bigaj.

----------------------------------------
Bug #4854: Invalid locale_charmap (CP0) when running as Windows Service
http://redmine.ruby-lang.org/issues/4854

Author: Rafal Bigaj
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 1.9.x
ruby -v: ruby 1.9.2p136


When ruby process is run as Windows Service the console codepage is not set, GetConsoleCP returns 0.
As a result function rb_locale_charmap refers to not existing codepage: CP0.
It has a dramatic performance drawback on the system when for ex. enumerating through ENV.
The attached patch simple checks if the GetConsoleCP() returns 0 and if so uses the actual system codepage.


-- 
http://redmine.ruby-lang.org