{"action":"created","issue":{"url":"https://api.github.com/repos/jline/jline3/issues/168","repository_url":"https://api.github.com/repos/jline/jline3","labels_url":"https://api.github.com/repos/jline/jline3/issues/168/labels{/name}","comments_url":"https://api.github.com/repos/jline/jline3/issues/168/comments","events_url":"https://api.github.com/repos/jline/jline3/issues/168/events","html_url":"https://github.com/jline/jline3/pull/168","id":257476045,"number":168,"title":"Use WriteConsoleW to write to Windows console","user":{"login":"Minecrell","id":3035868,"avatar_url":"https://avatars0.githubusercontent.com/u/3035868?v=4","gravatar_id":"","url":"https://api.github.com/users/Minecrell","html_url":"https://github.com/Minecrell","followers_url":"https://api.github.com/users/Minecrell/followers","following_url":"https://api.github.com/users/Minecrell/following{/other_user}","gists_url":"https://api.github.com/users/Minecrell/gists{/gist_id}","starred_url":"https://api.github.com/users/Minecrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Minecrell/subscriptions","organizations_url":"https://api.github.com/users/Minecrell/orgs","repos_url":"https://api.github.com/users/Minecrell/repos","events_url":"https://api.github.com/users/Minecrell/events{/privacy}","received_events_url":"https://api.github.com/users/Minecrell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2017-09-13T18:22:44Z","updated_at":"2017-09-15T15:26:12Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/jline/jline3/pulls/168","html_url":"https://github.com/jline/jline3/pull/168","diff_url":"https://github.com/jline/jline3/pull/168.diff","patch_url":"https://github.com/jline/jline3/pull/168.patch"},"body":"This is an attempt to fix #133 and #164 at the same time, without having to set a code page manually.\r\n\r\nFurther investigation of #164 has shown: Even when the UTF-8 code page is supported just fine (e.g. on Windows 10), it seems to be partially broken. As an example, with the system locale set to Chinese, the UTF-8 code page will produce incorrect characters to be displayed.\r\n\r\nSince we avoid all encoding problems for the input mechanism by using the Windows API to read a Unicode char directly, I've been looking for solutions to apply the same for console output. This pull request changes the Windows terminal implementation to use [`WriteConsoleW`](https://docs.microsoft.com/en-us/windows/console/writeconsole) to write Unicode text directly to the console window - bypassing all problems caused by the code pages.\r\n\r\nSince the Windows API accepts characters directly, the primary output for the Windows terminal now operates as `Writer`: the encoding step is skipped entirely. For compatibility reasons, we still need to support a `OutputStream`: some applications may use it directly through `Terminal.output()`.\r\nThe output stream now emulates the old behavior: it decodes the written bytes using the configured code page. Consequently, Unicode works only properly when using the `Writer` directly (through `Terminal.writer()`). This is the case for JLine's `LineReader` implementation and probably most other applications.\r\n\r\nI've tested this on Windows 10 with the system locale set to English, German and Chinese and various code pages and it now handles both #133 and #164 automatically, without having to change the code page. We still need to test if it works properly on older Windows versions."},"comment":{"url":"https://api.github.com/repos/jline/jline3/issues/comments/329815373","html_url":"https://github.com/jline/jline3/pull/168#issuecomment-329815373","issue_url":"https://api.github.com/repos/jline/jline3/issues/168","id":329815373,"user":{"login":"gnodet","id":84022,"avatar_url":"https://avatars3.githubusercontent.com/u/84022?v=4","gravatar_id":"","url":"https://api.github.com/users/gnodet","html_url":"https://github.com/gnodet","followers_url":"https://api.github.com/users/gnodet/followers","following_url":"https://api.github.com/users/gnodet/following{/other_user}","gists_url":"https://api.github.com/users/gnodet/gists{/gist_id}","starred_url":"https://api.github.com/users/gnodet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnodet/subscriptions","organizations_url":"https://api.github.com/users/gnodet/orgs","repos_url":"https://api.github.com/users/gnodet/repos","events_url":"https://api.github.com/users/gnodet/events{/privacy}","received_events_url":"https://api.github.com/users/gnodet/received_events","type":"User","site_admin":false},"created_at":"2017-09-15T15:26:12Z","updated_at":"2017-09-15T15:26:12Z","author_association":"OWNER","body":"@xldai Could you build jline from the following revision https://github.com/gnodet/jline3/tree/minecrell-WriteConsoleW and see how it behaves in Karaf on your system ?\r\nI've done a bit testing and it seems ok for me on my windows virtual box."}}
{"actor":{"display_login":"gnodet"}}