When working with text processing, data migration, or system integration in PowerShell, encoding challenges often arise. Unicode is now the default for most systems and applications.
However, situations may require conversion to ASCII—for instance, when supporting legacy applications, cleaning data, or prepping information for APIs that cannot handle special characters.
In this tutorial, I will explain how to convert unicode to ASCII using PowerShell with examples.
Unicode vs. ASCII
Unicode is a universal character encoding standard. It supports characters for almost every language, as well as symbols, emojis, and technical glyphs. Data is usually represented with UTF-8 or UTF-16 encoding, which allows for billions of possible characters.
ASCII, on the other hand, is an older and much more limited standard—covering only 128 characters, which includes the English alphabet, numbers, and several control symbols.
Converting Unicode to ASCII in PowerShell ensures compatibility, but can result in data loss—special characters, diacritics, and symbols not present in ASCII become question marks or are stripped out entirely.
Ensure to use PowerShell 5.1 or PowerShell 7+.
You can check the PowerShell version using the below cmdlet.
$PSVersionTable.PSVersionYou may need to adjust the script execution policy:
Set-ExecutionPolicy RemoteSignedOne of the most important points: Always back up files before batch conversions, as data loss from unmatched characters is permanent.
Check out Convert HEIC to JPG using PowerShell
Method 1: Using .NET Encoding Classes
PowerShell leverages the .NET framework. You can use the System.Text.Encoding class to handle conversions and encoding changes.
- Create a Unicode string:
$text = "Hello – World ©"- Convert to ASCII using .NET methods:
$text = "Hello – World ©"
$unicodeBytes = [System.Text.Encoding]::Unicode.GetBytes($text)
$asciiBytes = [System.Text.Encoding]::Convert([System.Text.Encoding]::Unicode, [System.Text.Encoding]::ASCII, $unicodeBytes)
$asciiText = [System.Text.Encoding]::ASCII.GetString($asciiBytes)
Write-Output $asciiText- Output:
Hello ? World ? - The special en-dash and copyright sign are both replaced with
?as ASCII does not support them
You can see the exact output in the screenshot below:

Pros and Cons:
- Pros: Uses built-in .NET. Fast. Simple for pure conversion.
- Cons: Unsupported Unicode characters become
?, which may hinder readability or corrupt intent.
Read Convert JSON to XML using PowerShell
Method 2: Removing Non-ASCII Characters with Regex
For strict scenarios demanding only printable ASCII, PowerShell’s -replace operator with regular expressions does the job.
- Remove Non-ASCII:
- Using hex range for standard ASCII (0x00 to 0x7F):
$text = "Data©2025✓ Powered"
$asciiText = $text -replace '[^\x00-\x7F]', ''
Write-Output $asciiTextOutput: Data2025 Powered
Now, all special Unicode symbols are completely gone, not replaced by ?
Here is the exact output in the screenshot below:

- Alternate: Remove Non-ASCII with Unicode block:
$asciiText = $text -creplace '\P{IsBasicLatin}'
Write-Output $asciiTextThis method removes every character outside standard ASCII (Latin block).
Use Cases:
- Cleaning log files
- Stripping user input for legacy systems
- Preparation for storage in ASCII-only databases
Check out Convert Bytes to GB in PowerShell
Method 3: Mapping Unicode Characters to Closest ASCII
When meaning should be preserved, mapping specific symbols to descriptive ASCII substitutes is extremely helpful.
- Define mapping:
$mappings = @{
"©" = "(c)"
"–" = "-"
"✓" = "OK"
}- Replace in text:
$mappings = @{
"©" = "(c)"
"–" = "-"
"✓" = "OK"
}
$text = "Company© – Verified✓"
foreach ($key in $mappings.Keys) {
$text = $text.Replace($key, $mappings[$key])
}
Write-Output $textOutput: Company(c) - VerifiedOK
Here is the exact output in the screenshot below:

Check out PowerShell Convert XML to Object
Method 4: Converting Files During Read/Write
If you need to convert entire files, utilize the encoding options in file reading and writing cmdlets.
- Write to ASCII
$text = "Hello – World ©"
[System.IO.File]::WriteAllText("unicode.txt", $text, [System.Text.Encoding]::Unicode)
$content = Get-Content "unicode.txt"
[System.IO.File]::WriteAllText("ascii.txt", $content, [System.Text.Encoding]::ASCII)Opening ascii.txt will reveal all unsupported characters replaced by ?
- Using Out-File
Get-Content "unicode.txt" | Out-File "ascii_via_outfile.txt" -Encoding ASCIIThis method is ideal for bulk conversions or automation scripts.
Check out Convert XML to CSV in PowerShell
Handling Special Cases and Data Loss
Unsupported Characters
Any Unicode code point outside of the ASCII range (like emojis, accented letters, and special symbols) will be lost or replaced. Diacritics (like é, ñ, å) do not survive the conversion—sometimes an alternative mapping is necessary for clarity.
When Not to Use ASCII Conversion
If working with non-English text (Hindi, Chinese, Arabic, etc.), converting to ASCII is likely to produce unreadable or corrupted data. Evaluate whether UTF-8 with normalization is more appropriate in such cases.
Check out PowerShell Convert Secure String to Plain Text
PowerShell Convert Unicode to ASCII Examples
Now, let me show you some examples.
- Cleaning API Input
$payload = $payload -replace '[^\x00-\x7F]', ''- Sanitizing Log Files
Get-Content "log.txt" | ForEach-Object { $_ -replace '[^\x00-\x7F]', '' } | Set-Content "clean_log.txt"- Database Text Preprocessing
Before loading large CSVs into a legacy system:
Import-Csv data.csv | ForEach-Object {
$_.Name = $_.Name -replace '[^\x00-\x7F]', ''
$_
} | Export-Csv clean_data.csv -NoTypeInformationBest Practices for Unicode to ASCII Conversion
- Always back up original data.
- Test each approach with representative examples—especially if scripts run automatically.
- Use mapping for symbols that have widely accepted ASCII equivalents.
- Communicate limitations to stakeholders, especially about lost characters or data integrity changes.
Conclusion
PowerShell makes it easy to convert Unicode to ASCII using .NET encoding classes, file output parameters, regular expressions, or custom mappings. Each method serves different requirements—from rough cleaning to meaning-preserving normalization. Always consider the value and visibility of data loss for your specific use case and automate backups or testing before full migration.
Do let me know in the comments below if it helps.
You may also like:
- Convert HTML to PDF in PowerShell
- Convert CSV to HTML Table in PowerShell
- Convert JSON to CSV in PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.