Title: Variable assigment to files ignores all encoding settings and uses ... ASCII? · Issue #2268 · PowerShell/PowerShell · GitHub
Open Graph Title: Variable assigment to files ignores all encoding settings and uses ... ASCII? · Issue #2268 · PowerShell/PowerShell
X Title: Variable assigment to files ignores all encoding settings and uses ... ASCII? · Issue #2268 · PowerShell/PowerShell
Description: On PowerShell 5.1 and 6 we're able to control the encoding of the pipe redirection operators so we can get UTF8 encoding when we redirect to file, however, using variable syntax and assignment does not work. Steps to reproduce Setting (o...
Open Graph Description: On PowerShell 5.1 and 6 we're able to control the encoding of the pipe redirection operators so we can get UTF8 encoding when we redirect to file, however, using variable syntax and assignment does...
X Description: On PowerShell 5.1 and 6 we're able to control the encoding of the pipe redirection operators so we can get UTF8 encoding when we redirect to file, however, using variable syntax and assignment ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/2268
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Variable assigment to files ignores all encoding settings and uses ... ASCII?","articleBody":"On PowerShell 5.1 and 6 we're able to control the encoding of the pipe redirection operators so we can get UTF8 encoding when we redirect to file, however, using variable syntax and assignment does not work.\n## Steps to reproduce\n\nSetting (or appending) the content using variable notation and = or += doesn't respect any of the encoding settings.\n\n``` posh\nPS C:\\Users\\Jaykul> ${C:gear.txt} = \"$([char]0x263C)\"\nPS C:\\Users\\Jaykul> gc .\\gear.txt -Raw -Encoding Byte | % { \"{0:x2} \" -f $_ }\n3f 0d 0a\nPS C:\\Users\\Jaykul> ${C:gear.txt}\n?\n```\n## Expected behavior\n\nIt should work the same way that pipe redirection works:\n\n``` posh\nPS C:\\Users\\Jaykul> [char]0x263C > gear.txt\nPS C:\\Users\\Jaykul> ${C:gear.txt}\n☼\nPS C:\\Users\\Jaykul> gc .\\gear.txt -Raw -Encoding Byte | % { \"{0:x2} \" -f $_ }\nff fe 3c 26 0d 00 0a 00\n```\n\nIn PS 5.1 and 6, I can change the default to UTF8, and it encodes it that way:\n\n``` posh\nPS C:\\Users\\Jaykul> $PSDefaultParameterValues[\"Out-File:Encoding\"] = \"utf8\"\nPS C:\\Users\\Jaykul> [char]0x263C > gear.txt\nPS C:\\Users\\Jaykul> gc .\\gear.txt -Raw -Encoding Byte | % { \"{0:x2} \" -f $_ }\nef bb bf e2 98 bc 0d 0a\n```\n## Actual behavior\n\nNeither the DefaultParameterValues for Out-File/Set-Content/Add-Content, nor the `$OutputEncoding` are respected ...\n## Environment data\n\n\u003c!-- provide the output of $PSVersionTable -->\n\n``` powershell\n> $PSVersionTable\n\nName Value\n---- -----\nPSRemotingProtocolVersion 2.3\nSerializationVersion 1.1.0.1\nGitCommitId v6.0.0-alpha.9\nBuildVersion 3.0.0.0\nPSEdition Core\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\nPSVersion 6.0.0-alpha\nWSManStackVersion 3.0\nCLRVersion\n```\n","author":{"url":"https://github.com/Jaykul","@type":"Person","name":"Jaykul"},"datePublished":"2016-09-15T03:50:15Z","url":"https://github.com/PowerShell/PowerShell/issues/2268"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:ee24db33-75c1-22ed-6cb8-6555de32dac9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A49E:3DF74F:A9ED8:E2530:6AFD1D16 |
| html-safe-nonce | 8f56ff9843f2af99871ea1cdc48edbc7609e612cb2f579329202f3949c27dde5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDlFOjNERjc0RjpBOUVEODpFMjUzMDo2QUZEMUQxNiIsInZpc2l0b3JfaWQiOiI3NjUxMDc5NzczOTU4Nzc0MDM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8a8a3752f8b21aa3d5bf570685ceb3665a144ce0c4d180edb9a674ca72af352f |
| hovercard-subject-tag | issue:177081740 |
| 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/2268/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f90a727d25f9b46f3155636608cff2ce403abb1dc2e5b386a6ac0a7cd586396a/PowerShell/PowerShell/issues/2268 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f90a727d25f9b46f3155636608cff2ce403abb1dc2e5b386a6ac0a7cd586396a/PowerShell/PowerShell/issues/2268 |
| og:image:alt | On PowerShell 5.1 and 6 we're able to control the encoding of the pipe redirection operators so we can get UTF8 encoding when we redirect to file, however, using variable syntax and assignment does... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jaykul |
| hostname | github.com |
| expected-hostname | github.com |
| None | 065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19 |
| 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 | 941021edf0c2ec58298f4a2c8f27ae507d129c92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width