Title: Table format has been broken when output column contains east asian fullwidth characters · Issue #6290 · PowerShell/PowerShell · GitHub
Open Graph Title: Table format has been broken when output column contains east asian fullwidth characters · Issue #6290 · PowerShell/PowerShell
X Title: Table format has been broken when output column contains east asian fullwidth characters · Issue #6290 · PowerShell/PowerShell
Description: Steps to reproduce # make directories contains east asian fullwidth characters. # in this example, I use Japanese. mkdir .\Test cd .\Test mkdir Hello mkdir HelloWorld mkdir Helloワールド mkdir ハロー mkdir ハローワールド # invoke Get-ChildItem (output...
Open Graph Description: Steps to reproduce # make directories contains east asian fullwidth characters. # in this example, I use Japanese. mkdir .\Test cd .\Test mkdir Hello mkdir HelloWorld mkdir Helloワールド mkdir ハロー mkdi...
X Description: Steps to reproduce # make directories contains east asian fullwidth characters. # in this example, I use Japanese. mkdir .\Test cd .\Test mkdir Hello mkdir HelloWorld mkdir Helloワールド mkdir ハロー mkdi...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/6290
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Table format has been broken when output column contains east asian fullwidth characters","articleBody":"Steps to reproduce\r\n------------------\r\n\r\n```powershell\r\n# make directories contains east asian fullwidth characters.\r\n# in this example, I use Japanese.\r\nmkdir .\\Test\r\ncd .\\Test\r\nmkdir Hello\r\nmkdir HelloWorld\r\nmkdir Helloワールド\r\nmkdir ハロー\r\nmkdir ハローワールド\r\n\r\n# invoke Get-ChildItem (output table format by default)\r\nGet-ChildItem\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nTable layout is not broken.\r\n\r\ne.g. on Windows PowerShell 5.1\r\n\r\n\r\n\r\nActual behavior\r\n---------------\r\n\r\nTable layout has been broken. \r\n\r\n\r\n\r\nIn this case, the last column(`Name`) is broken. \r\nBut the column other than the last column will also be broken. \r\n\r\n\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\n\u003e $PSVersionTable\r\nName Value\r\n---- -----\r\nPSVersion 6.0.1\r\nPSEdition Core\r\nGitCommitId v6.0.1\r\nOS Microsoft Windows 10.0.16299\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n\r\nThis problem occurs on all platforms.\r\n\r\nCause\r\n----------------\r\n\r\nThe root cause is [ConsoleControl.LengthInBufferCells()](https://github.com/PowerShell/PowerShell/blob/v6.0.1/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs#L2763) method returns invalid value when `str` parameter contains east asian fullwidth characters. \r\n\r\nhttps://github.com/PowerShell/PowerShell/blob/67c9ae47f81a38ee3fcc1e16b187b79fb9cbe148/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs#L2763-L2786\r\n\r\nWhen [TableWriter](https://github.com/PowerShell/PowerShell/blob/v6.0.1/src/System.Management.Automation/FormatAndOutput/common/TableWriter.cs) creates table row line, `ConsoleControl.LengthInBufferCells()` method is called to get row character width.\r\n\r\n`ConsoleControl.LengthInBufferCells()` method is expected to return a value according to the width of the character. \r\nGenerally, east asian fullwidth characters(e.g. Japanese) are expected to return 2 or more per a character, but current version of `ConsoleControl.LengthInBufferCells()` simply returns character length.\r\n\r\n```csharp\r\n// length expected 6(3 fullwidth characters), but actual returns 3.\r\nConsoleControl.LengthInBufferCells(\"ハロー\", 0, false); \r\n```\r\n\r\nSo, the padding in the last column(`Name`) has be greater than expected and then Table layout has been broken.\r\n\r\n```powershell\r\n# expected 120 characters width\r\n\"d----- 2018/03/02 15:52 Hello \"\r\n# actual 123 characters width\r\n\"d----- 2018/03/02 15:52 ハロー \" \r\n```\r\n\r\nReference 1\r\n----------------\r\n\r\nThe past version of `ConsoleControl.LengthInBufferCells()` method calls [LengthInBufferCellsFE()](https://github.com/PowerShell/PowerShell/blob/v6.0.0-alpha.9/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs#L2875) method internally. (FE means Far East?)\r\n\r\nhttps://github.com/PowerShell/PowerShell/blob/f46284414e9dda57eff3cdba7e61570a9a83e27e/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs#L2875-L3036\r\n\r\nThis `LengthInBufferCellsFE()` method handles the length of east asian fullwidth characters correctly, but it was removed at f604b0e3f063c7a89db025f11b320e5c9797c6e0 .\r\n\r\nReference 2\r\n----------------\r\n\r\nTechnical report about East Asian Width.\r\n\r\n* [East Asian Width](http://unicode.org/reports/tr11/)\r\n","author":{"url":"https://github.com/stknohg","@type":"Person","name":"stknohg"},"datePublished":"2018-03-02T07:19:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/6290/PowerShell/issues/6290"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6dc5e124-a8b3-6953-f382-1323c546014a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8CE6:70966:38A5D:4B0E5:6A55829F |
| html-safe-nonce | 08d3b53c39ec45ba6110a75eec9e89b8fdb663a0acda101cc33228a659a082bc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0U2OjcwOTY2OjM4QTVEOjRCMEU1OjZBNTU4MjlGIiwidmlzaXRvcl9pZCI6Ijg5MTMzOTUxNTIxNDU3MTE3NzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 00ef01fadd1f797fbfbc267aca20185ed00b1d86592b1e3772a57a5ba3a91685 |
| hovercard-subject-tag | issue:301675170 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/6290/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f4623cfe56c9933cff9a86aeb712576c5c8cbe94c72e1b485e5cd470fc80877d/PowerShell/PowerShell/issues/6290 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f4623cfe56c9933cff9a86aeb712576c5c8cbe94c72e1b485e5cd470fc80877d/PowerShell/PowerShell/issues/6290 |
| og:image:alt | Steps to reproduce # make directories contains east asian fullwidth characters. # in this example, I use Japanese. mkdir .\Test cd .\Test mkdir Hello mkdir HelloWorld mkdir Helloワールド mkdir ハロー mkdi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | stknohg |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3215163789b3dc58dba97bd78a30c20c949f477f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width