Skip to content

Commit

Permalink
Create Remove-Accents-using-Cyrillic.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
ninmonkey authored Jul 19, 2024
1 parent bafeb97 commit c6258ef
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions encoding/Remove-Accents-using-Cyrillic.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function RemoveAccents {
<#
.synopsis
Strip accents from text using cyrillic encoding. warning: this is a simple method, but does remove non-accented characters that weren't encodable
#>
param( [string] $Text )
$enc = [Text.Encoding]::GetEncoding('iso-8859-5')
$enc.GetString( $enc.GetBytes( $Text ) )
}

RemoveAccents 'foo bår'

<#
I'm not 100% this is the best cyrillic to use, there's a few
Pwsh> [Text.Encoding]::GetEncodings() | ? displayname -Match 'cyr|cry'
CodePage Name DisplayName
-------- ---- -----------
20880 IBM880 IBM EBCDIC (Cyrillic Russian)
866 cp866 Cyrillic (DOS)
21866 koi8-u Cyrillic (KOI8-U)
1251 windows-1251 Cyrillic (Windows)
10007 x-mac-cyrillic Cyrillic (Mac)
28595 iso-8859-5 Cyrillic (ISO)
20866 koi8-r Cyrillic (KOI8-R)
855 IBM855 OEM Cyrillic
21025 cp1025 IBM EBCDIC (Cyrillic Serbian-Bulgarian)
#>

0 comments on commit c6258ef

Please sign in to comment.