Title: `StringDecorated` class doesn't recognize `
Open Graph Title: `StringDecorated` class doesn't recognize `
X Title: `StringDecorated` class doesn't recognize `
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/19246
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`StringDecorated` class doesn't recognize `\u003cesc\u003e[m ` as the ANSI reset escape sequence, requires `\u003cesc\u003e[0m`","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\n``\"`e[m \"`` is a valid ANSI escape sequence that resets current formatting, short for ``\"`e[0m \"`` \r\n\r\nThe `StringDecorated` currently doesn't recognize it, and retains it as part of the data when plain-text conversion is requested.\r\n\r\n```powershell\r\n# If you output the string directly to the terminal, you'll see that the trailing \".\" is NOT green anymore,\r\n# proving that \"`e[m\"` was effective in resetting the color.\r\n([System.Management.Automation.Internal.StringDecorated]::new(\"`e[32mgreen`e[m.\")).ToString('PlainText') | Format-Hex\r\n```\r\n\r\nNote:\r\n\r\n* Because _terminals_ recognize ``\"`e[m \"`` correctly, the problem is usually _hidden_ when the class is used behind the scenes in conjunction with `$PSStyle.OutputRendering = 'PlainText'`, e.g. with\r\n`$PSStyle.OutputRendering = 'PlainText'; wsl -e printf '\\e[32mgreen\\e[m.' | Out-Host`.\r\n\r\n* However, due to the - inappropriately closed - #18771 - it currently _does_ surface in `conhost.exe` windows on Windows.\r\n\r\n\r\n\r\n### Expected behavior\r\n\r\n```console\r\nLabel: String (System.String) \u003c7E780A95\u003e\r\n\r\n Offset Bytes Ascii\r\n 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\r\n ------ ----------------------------------------------- -----\r\n0000000000000000 67 72 65 65 6E 2E green.\r\n```\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\nLabel: String (System.String) \u003c56784E4B\u003e\r\n\r\n Offset Bytes Ascii\r\n 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\r\n ------ ----------------------------------------------- -----\r\n0000000000000000 67 72 65 65 6E 1B 5B 6D 2E green�[m.\r\n```\r\n\r\nNote the extraneous `�[m` part in the `Ascii` column, showing that `` `e[m `` was unexpectedly retained.\r\n\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nPowerShell Core 7.4.0-preview.1\r\n```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2023-02-28T21:45:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/19246/PowerShell/issues/19246"}
| 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:3fd6dc0d-f412-4729-7dae-932187b57358 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCC6:20E8B8:2847855:36D01A6:6A5440D5 |
| html-safe-nonce | cbf57c6a25fac9b80a3c0c791923e7dc7b60a7ff968de0c6f903c54bf40ef0ef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0M2OjIwRThCODoyODQ3ODU1OjM2RDAxQTY6NkE1NDQwRDUiLCJ2aXNpdG9yX2lkIjoiNTU5NDgwNjc5MTYzNDY5ODQ1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 132fa6f15d66d3481bd4c7f6ac5a54379fd8cee57b7473ea081e2d9109007242 |
| hovercard-subject-tag | issue:1603864554 |
| 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/19246/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4f94a25540fedfd17a130684daacf02c1955f14f474ffc99cbe517fb2bedc651/PowerShell/PowerShell/issues/19246 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4f94a25540fedfd17a130684daacf02c1955f14f474ffc99cbe517fb2bedc651/PowerShell/PowerShell/issues/19246 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width