我在想未知選項用於二進制文件連接。什麼時候應該使用'Unknown'作爲-Encoding參數?
http://technet.microsoft.com/en-us/library/dd315299.aspx
未知的編碼類型是未知的 或無效。該數據可以被視爲 二進制。
但{Get-Content binary.dat -Encoding Unknown}
不返回字節數組而是字符串數組。
PS > $a = Get-Content $PSHOME\WTRInstaller.ico -Encoding Unknown
PS > $b = Get-Content $PSHOME\WTRInstaller.ico -Encoding Byte
PS > $a[0].GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
PS > $b[0].GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Byte System.ValueType
即使我將$ a轉換爲字節數組,它也不符合$ b。
PS > [Text.Encoding]::Unicode.GetBytes($a)
PS > compare $c[0..10] $b[0..10]
InputObject SideIndicator
----------- -------------
10 =>
32 <=
何時應該使用「未知」?
賈爾夫,謝謝你的好編輯! – hoge 2009-12-13 03:52:08