Skip to content

Commit c6258ef

Browse files
authored
Create Remove-Accents-using-Cyrillic.ps1
1 parent bafeb97 commit c6258ef

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
function RemoveAccents {
2+
<#
3+
.synopsis
4+
Strip accents from text using cyrillic encoding. warning: this is a simple method, but does remove non-accented characters that weren't encodable
5+
#>
6+
param( [string] $Text )
7+
$enc = [Text.Encoding]::GetEncoding('iso-8859-5')
8+
$enc.GetString( $enc.GetBytes( $Text ) )
9+
}
10+
11+
RemoveAccents 'foo bår'
12+
13+
<#
14+
I'm not 100% this is the best cyrillic to use, there's a few
15+
16+
Pwsh> [Text.Encoding]::GetEncodings() | ? displayname -Match 'cyr|cry'
17+
18+
CodePage Name DisplayName
19+
-------- ---- -----------
20+
20880 IBM880 IBM EBCDIC (Cyrillic Russian)
21+
866 cp866 Cyrillic (DOS)
22+
21866 koi8-u Cyrillic (KOI8-U)
23+
1251 windows-1251 Cyrillic (Windows)
24+
10007 x-mac-cyrillic Cyrillic (Mac)
25+
28595 iso-8859-5 Cyrillic (ISO)
26+
20866 koi8-r Cyrillic (KOI8-R)
27+
855 IBM855 OEM Cyrillic
28+
21025 cp1025 IBM EBCDIC (Cyrillic Serbian-Bulgarian)
29+
30+
#>

0 commit comments

Comments
 (0)