https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112014-11-10T07:14:14ZRuby Issue Tracking SystemRuby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=498662014-11-10T07:14:14Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/49866/diff?detail_id=35998">diff</a>)</li><li><strong>Category</strong> set to <i>ext</i></li><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li><li><strong>Target version</strong> set to <i>2.2.0</i></li><li><strong>Backport</strong> changed from <i>2.0.0: UNKNOWN, 2.1: UNKNOWN</i> to <i>2.0.0: REQUIRED, 2.1: REQUIRED</i></li></ul><p>Is your <code>Encoding.default_external</code> Windows-1257?</p> Ruby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=498682014-11-10T08:24:53Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>Applied in changeset r48360.</p>
<hr>
<p>win32.c: login name encoding</p>
<ul>
<li>ext/etc/etc.c (etc_getlogin): set login name encoding properly.<br>
<a href="/issues/10493">[ruby-core:66163]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Wrong encoding for Etc.getlogin in Windows (Closed)" href="https://bugs.ruby-lang.org/issues/10493">#10493</a>]</li>
</ul> Ruby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=498752014-11-10T19:46:24Zdavispuh (Dāvis Mosāns)
<ul></ul><p>No, <em>Encoding.default_external</em> is based on current consoles encoding. And by default it is IBM775, but can be different for each opened console. Also it's not related to Encoding which is used by Windows ANSI API. Windows-1257 encoding is set in Control Panel for non-Unicode programs and will be used for all Windows ANSI functions. Proper way is to always use Windows Unicode/Wide API and then it will be encoded with UTF-16.</p>
<p>Thanks for patch, I'll test it when it will be released.</p> Ruby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=498902014-11-11T01:59:00Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul></ul><p>Dāvis Mosāns wrote:</p>
<blockquote>
<p>No, <em>Encoding.default_external</em> is based on current consoles encoding. And by default it is IBM775, but can be different for each opened console. Also it's not related to Encoding which is used by Windows ANSI API. Windows-1257 encoding is set in Control Panel for non-Unicode programs and will be used for all Windows ANSI functions.</p>
</blockquote>
<p>Can you say which section of the control panel that is?</p>
<blockquote>
<p>Proper way is to always use Windows Unicode/Wide API and then it will be encoded with UTF-16.</p>
<p>Thanks for patch, I'll test it when it will be released.</p>
</blockquote>
<p>It would be highly desirable to test it before it's released.</p> Ruby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=499002014-11-11T14:29:14Zdavispuh (Dāvis Mosāns)
<ul></ul><p>Control Panel -> Region -> Administrative -> Change system locale</p>
<p><a href="http://www.7tutorials.com/changing-display-language-used-non-unicode-programs" class="external">Here's article describing how to change locale for Windows 7 and 8</a></p>
<p>For Windows 7<br>
<img src="http://www.7tutorials.com/files/img/non_unicode_language/non_unicode4.png" alt="Windows 7"></p>
<p>For Windows 8<br>
<img src="http://www.7tutorials.com/files/img/non_unicode_language/non_unicode6.png" alt="Windows 8"></p>
<p>To test it now I would need to setup environment and compile Ruby, but I never have done that and currently don't really have time for it. Anyway I'll see maybe I will be able to find time for it someday.</p> Ruby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=499012014-11-11T14:35:24Zluislavena (Luis Lavena)luislavena@gmail.com
<ul></ul><p>Davis,</p>
<p>You can build Ruby easily by using RubyInstaller recipes:</p>
<p><a href="https://github.com/oneclick/rubyinstaller" class="external">https://github.com/oneclick/rubyinstaller</a></p>
<p>You will also need a clone of Ruby source code and usage of <code>LOCAL</code> to indicate the PATH where to find Ruby source code.</p>
<p>See examples in RubyInstaller's readme.</p>
<p>Cheers.</p> Ruby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=499052014-11-11T16:27:06Zdavispuh (Dāvis Mosāns)
<ul></ul><p>Thanks, that was surprisingly easy. Only trunk didn't build so I compiled from ruby_2_1 branch and cherry-picked r48360, r48364<br>
Now I can confirm that patch works.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">name</span> <span class="o">=</span> <span class="no">Etc</span><span class="p">.</span><span class="nf">getlogin</span>
<span class="nb">puts</span> <span class="nb">name</span><span class="p">.</span><span class="nf">inspect</span> <span class="c1"># "D\u0101vis"</span>
<span class="nb">puts</span> <span class="nb">name</span><span class="p">.</span><span class="nf">encoding</span> <span class="c1"># UTF-8</span>
</code></pre>
<p>But looks like encoding for string outputting have been broken somewhere (I hope it's fixed in some commits not yet merged in this branch)</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">puts</span> <span class="s2">"</span><span class="se">\u</span><span class="s2">0101"</span>
<span class="o">=></span> <span class="err">ā</span> <span class="c1"># on released Ruby 2.1.4p265</span>
<span class="o">=></span> <span class="err">Ä</span><span class="p">?</span> <span class="c1"># on 2.1.5p272, I just compiled from ruby_2_1 branch</span>
</code></pre>
<p>It used to be that when outputting string it's encoded to <code>Encoding.default_external</code>, but that's not the case for this.</p> Ruby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=501572014-11-28T07:33:22Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Backport</strong> changed from <i>2.0.0: REQUIRED, 2.1: REQUIRED</i> to <i>2.0.0: DONE, 2.1: REQUIRED</i></li></ul><p>Backported into <code>ruby_2_0_0</code> at r48634.</p>
<p>memo:<br>
I changed the patch a little, because 2.0.0 doesn't have rb_w32_wstr_to_mbstr().<br>
2.1 has the function, so I guess it's no problem to backport to 2.1 from trunk.</p> Ruby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=513382015-02-02T14:01:00Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.0.0: DONE, 2.1: REQUIRED</i> to <i>2.0.0: DONE, 2.1: DONE</i></li></ul><p>Backported into <code>ruby_2_1</code> at r49473.</p>
<p>usa-san, thank you for your advice. I'll keep my eyes on RubyCI, especially on vc-x64.</p> Ruby master - Bug #10493: Wrong encoding for Etc.getlogin in Windowshttps://bugs.ruby-lang.org/issues/10493?journal_id=513402015-02-02T14:48:41Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul></ul><p>Tomoyuki Chikanaga wrote:</p>
<blockquote>
<p>Backported into <code>ruby_2_1</code> at r49473.<br>
usa-san, thank you for your advice. I'll keep my eyes on RubyCI, especially on vc-x64.</p>
</blockquote>
<p>It seems good. (I've tested on my box.)<br>
Thank you!</p>