Title: Prepare for BOM-less UTF-8 default character encoding with respect to $OutputEncoding and console code page · Issue #4681 · PowerShell/PowerShell · GitHub
Open Graph Title: Prepare for BOM-less UTF-8 default character encoding with respect to $OutputEncoding and console code page · Issue #4681 · PowerShell/PowerShell
X Title: Prepare for BOM-less UTF-8 default character encoding with respect to $OutputEncoding and console code page · Issue #4681 · PowerShell/PowerShell
Description: BOM-less UTF-8 character encoding is coming as the default for PowerShell Core on all platforms. Two attendant changes are required: Preference variable $OutputEncoding, which currently defaults to ASCII, must default to [System.Text.UTF...
Open Graph Description: BOM-less UTF-8 character encoding is coming as the default for PowerShell Core on all platforms. Two attendant changes are required: Preference variable $OutputEncoding, which currently defaults to...
X Description: BOM-less UTF-8 character encoding is coming as the default for PowerShell Core on all platforms. Two attendant changes are required: Preference variable $OutputEncoding, which currently defaults to...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/4681
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Prepare for BOM-less UTF-8 default character encoding with respect to $OutputEncoding and console code page","articleBody":"BOM-less UTF-8 character encoding [is coming as the default for PowerShell Core on all platforms](https://github.com/PowerShell/PowerShell-RFC/issues/71#issuecomment-306614751).\r\n\r\nTwo attendant changes are required:\r\n\r\n* Preference variable `$OutputEncoding`, which currently defaults to ASCII, must default to `[System.Text.UTF8Encoding]::new()` (UTF-8 with no BOM), or, perhaps preferably, _not_ predefine this variable and default to that encoding (the internally used default) in its absence.\r\n\r\n * `$OutputEncoding` tells PowerShell what character encoding to use when sending output _to_ external utilities.\r\n\r\n* Console / terminal character encoding:\r\n\r\n * On _Windows_, `[Console]::InputEncoding` and `[Console]::OutputEncoding` must both be set to `[System.Text.UTF8Encoding]::new()`, which is the equivalent of configuring a console window to use code page `65001` (UTF-8) or executing `chcp 65001` _before_ PowerShell is launched.\r\n\r\n * `[Console]::OutputEncoding` tells PowerShell what encoding to assume when reading output _from_ external utilities.\r\n\r\n * On Windows, the Start Menu shortcut that is created during installation should be preconfigured to open a console window with code page `65001`.\r\n\r\n * Conceivably, PowerShell should _automatically_ switch to the `65001` code page in case it is launched from a console window with a different active code page (such as from `cmd.exe`), though it is worth noting that this change in encoding by default remains in effect until the window is closed (even after exiting PowerShell and returning to `cmd.exe`; perhaps a warning could be issued on startup).\r\n\r\n * On _Unix_ platforms with UTF-8-based locales, which are the norm these days, no action is required.\r\n\r\n * To be determined: How should the rare event of being invoked from a terminal with a different active character encoding be handled? Changing the encoding on the fly, as on Windows, is not guaranteed to work. Perhaps a warning on startup is sufficient.\r\n\r\n---\r\n\r\nBefore the above is implemented, the **interim workaround** to make a console window / terminal use UTF-8 consistently is the following command:\r\n\r\n```powershell\r\n$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new()\r\n\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-beta.6\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-08-27T03:32:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":16},"url":"https://github.com/4681/PowerShell/issues/4681"}
| 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:cc066ee2-4583-71df-8a15-2993b797d157 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF6A:A3218:15D6F70:1DCEBBA:6A572511 |
| html-safe-nonce | ce2208acadd70ed9d31cd2382f664fedfa99f445ad039c73406bf8674cc56af7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjZBOkEzMjE4OjE1RDZGNzA6MURDRUJCQTo2QTU3MjUxMSIsInZpc2l0b3JfaWQiOiI4NjA3NzU0MzcwMTQ1NTI3MDU3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4c3c3886b4d66908130714fe55aeafd244a93aa99ad9bae72661bbc4dbc0e540 |
| hovercard-subject-tag | issue:253138583 |
| 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/4681/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ebbfd813bec548a6ff44bebf74886d2ca6939d9d4d739eba1eed926673b5dc5c/PowerShell/PowerShell/issues/4681 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ebbfd813bec548a6ff44bebf74886d2ca6939d9d4d739eba1eed926673b5dc5c/PowerShell/PowerShell/issues/4681 |
| og:image:alt | BOM-less UTF-8 character encoding is coming as the default for PowerShell Core on all platforms. Two attendant changes are required: Preference variable $OutputEncoding, which currently defaults to... |
| 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 | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| 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 | 2576d1f0198cf1588faf2edf27f1ed120903be10 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width