> ## Documentation Index
> Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# powershell/PSUseUTF8EncodingForHelpFile

> Use UTF8 Encoding For Help File

`powershell/PSUseUTF8EncodingForHelpFile` is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.

| Property | Value             |
| -------- | ----------------- |
| Severity | Warning           |
| Category | PSScriptAnalyzer  |
| Default  | Disabled in tally |
| Auto-fix | No                |

<Note>
  tally disables this rule by default because Dockerfile `RUN` bodies are inline strings, not
  files on disk with encoding metadata. Re-enable it with
  `include = ["powershell/PSUseUTF8EncodingForHelpFile"]` or by setting
  `rules.powershell.PSUseUTF8EncodingForHelpFile.severity = "warning"` in `.tally.toml`.
</Note>

## Description

Check that an `about_` help file uses UTF-8 encoding. The filename must start with `about_` and end
with `.help.txt`. The rule uses the **CurrentEncoding** property of the **StreamReader** class to
determine the encoding of the file.

## How

For PowerShell commands that write to files, ensure that you set the encoding parameter to `utf8`,
`utf8BOM`, or `utf8NoBOM`.

When you create a help file using a text editor, ensure that the editor is configured to save the
file in a UTF8 format. Consult the documentation for your text editor for instructions on how to
save files with a specific encoding.

## Further reading

For more information, see the following articles:

* `System.IO.StreamReader`
* [about\_Character\_Encoding](/powershell/module/microsoft.powershell.core/about/about_character_encoding)
* [Set-Content](https://learn.microsoft.com/powershell/module/microsoft.powershell.management/set-content)
* [Understanding file encoding in VS Code and PowerShell](/powershell/scripting/dev-cross-plat/vscode/understanding-file-encoding)

## Source

This rule documentation is adapted from Microsoft's PSScriptAnalyzer documentation for
[UseUTF8EncodingForHelpFile](https://github.com/MicrosoftDocs/PowerShell-Docs-Modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseUTF8EncodingForHelpFile.md),
licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
