Skip to content

Instantly share code, notes, and snippets.

@dhmacher
Created June 30, 2021 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dhmacher/c429a6dfe1cfe3d72e9633cbf05eefe3 to your computer and use it in GitHub Desktop.
Save dhmacher/c429a6dfe1cfe3d72e9633cbf05eefe3 to your computer and use it in GitHub Desktop.
Converts an ISO-8859-1 string to UTF-8. Handy on when you receive a response from a web API that does not specify the codepage.
# https://stackoverflow.com/a/53034595/5471286
function ConvertTo-UTF8 {
param(
[Parameter(ValueFromPipeline)] [string]$ISOString
)
return ([Text.Encoding]::UTF8.GetString( `
[Text.Encoding]::GetEncoding(28591).GetBytes($ISOString)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment