2012-03-28 6 views
6

Gegeben:Wie wird eine UTF16-codierte Datei als ASCII (oder UTF8) in der Powershell-Eingabeaufforderung ausgegeben?

PS C:\work> cat .\aclfile 
e 7 2 2 d 2 7 6 5 c c c 6 9 3 0 8 5 8 e 5 e 8 7 1 c 1 2 d 7 3 c _ 1 1 4 e 5 6 e b - b 5 1 8 - 4 6 1 2 - 9 d b a - 7 c 6 6 2 5 f 6 c 5 3 1 

D : A I (A ; ; F A ; ; ; S Y) (A ; ; F A ; ; ; B A) (A ; ; F R ; ; ; S - 1 - 5 - 5 - 0 - 9 7 3 4 9) (A ; ; F R ; ; ; S - 1 - 5 - 2 1 - 2 0 2 0 4 5 9 8 2 - 2 2 3 5 5 2 7 6 6 3 - 5 2 2 7 6 5 8 3 8 - 1 0 0 0) 

gesucht

PS C:\work> something .\aclfile 
e722d2765ccc6930858e5e871c12d73c_114e56eb-b518-4612-9dba-7c6625f6c531 

D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;FR;;;S-1-5-5-0-97349)(A;;FR;;;S-1-5-21-202045982-2235527663-522765838-1000) 

Wie kann ich es tun?

Danke.

Antwort

6

Versuch:

PS C:\work> cat .\aclfile -encoding UTF8 # or String, Unicode, Byte, 
BigEndianUnicode, UTF7, Ascii 
+1

Wenn es UTF16 (LE) verwenden '-Encoding Unicode' ist. Wenn es UTF16 (BE) ist, verwenden Sie '-Encoding BigEndianUnicode'. Wenn es eine Stückliste gibt, können Sie diese kleine Funktion verwenden, um festzustellen, welche: http://stackoverflow.com/questions/9121579/powershell-out-file-prevent-encoding-changes –

+0

Unicode hat den Trick. Vielen Dank. – mark

+1

Ich wollte nur darauf hinweisen, dass der '-Encoding'-Parameter für' cat' (aka 'Get-Content') auf der [offiziellen Dokumentationsseite] fehlt (http://technet.microsoft.com/en-us/library) /dd347719.aspx) für PowerShell 2.0. Es wurde 2009 als Community-Inhalt hinzugefügt (siehe unten auf der Seite). –

Verwandte Themen