2011-02-09 56 views
0

我想做一些編輯二進制plist文件的腳本。 plist描述了DVD studio pro文件中包含的對象。看起來,DVD studio pro中的文本框在plist中被編碼爲base64數據,該數據描述了文本字符串及其格式。我似乎無法弄清楚如何理解這些數據。理想情況下,我希望能夠改變文本字符串,但不能格式化。以下內容似乎描述了一個文本框,其中顯示「此處的菜單標題」。有兩個字符串,一個叫做「字典」,另一個叫「字符串」;都是CFData。任何想法如何解析或將其轉換爲我可以直接編輯的格式?我一直在玩可可中寫一點轉換器,但還沒有運氣。格式化文本編碼在二進制plist

<dict> 
              <key>Dictionary</key> 
              <data> 
          BAtzdHJlYW10 
          eXBlZIHoA4QB 
          QISEhAxOU0Rp 
          Y3Rpb25hcnkA 
          hIQITlNPYmpl 
          Y3QAhYQBaQaS 
          hISECE5TU3Ry 
          aW5nAZSEASsG 
          TlNGb250hpKE 
          hIQGTlNGb250 
          HpSVJIQFWzM2 
          Y10GAAAAGgAA 
          AP/+TAB1AGMA 
          aQBkAGEARwBy 
          AGEAbgBkAGUA 
          AACEAWYVhAFj 
          AJsBmwCbAIaS 
          hJaXB05TQ29s 
          b3KGkoSEhAdO 
          U0NvbG9yAJSb 
          AYQEZmZmZoPz 
          8nI/g/Dvbz+D 
          7OtrPwGGkoSW 
          lwtOU0V4cGFu 
          c2lvboaShISE 
          CE5TTnVtYmVy 
          AISEB05TVmFs 
          dWUAlIQBKoSa 
          moNHx9c9hpKE 
          lpcNTlNPYmxp 
          cXVlbmVzc4aS 
          hJ6ghIQBZKEA 
          hpKElpcQTlNQ 
          YXJhZ3JhcGhT 
          dHlsZYaShISE 
          EE5TUGFyYWdy 
          YXBoU3R5bGUA 
          lIQEQ0NAUwAA 
          hQCGkoSWlxFO 
          U0JhY2tncm91 
          bmRDb2xvcoaS 
          hJubA4QCZmYA 
          AIaG 
              </data> 
              <key>String</key> 
              <data> 
          BAtzdHJlYW10 
          eXBlZIHoA4QB 
          QISEhBJOU0F0 
          dHJpYnV0ZWRT 
          dHJpbmcAhIQI 
          TlNPYmplY3QA 
          hZKEhIQITlNT 
          dHJpbmcBlIQB 
          Kw9OZW51IFRp 
          dGxlIEhlcmWG 
          hAJpSQEPkoSE 
          hAxOU0RpY3Rp 
          b25hcnkAlIQB 
          aQWShJaWDU5T 
          T2JsaXF1ZW5l 
          c3OGkoSEhAhO 
          U051bWJlcgCE 
          hAdOU1ZhbHVl 
          AJSEASqEhAFk 
          nQCGkoSWlgtO 
          U0V4cGFuc2lv 
          boaShJuchIQB 
          Zp6DR8fXPYaS 
          hJaWEE5TUGFy 
          YWdyYXBoU3R5 
          bGWGkoSEhBBO 
          U1BhcmFncmFw 
          aFN0eWxlAJSE 
          BENDQFMAAIUA 
          hpKElpYGTlNG 
          b250hpKEhIQG 
          TlNGb250HpSZ 
          JIQFWzM2Y10G 
          AAAAGgAAAP/+ 
          TAB1AGMAaQBk 
          AGEARwByAGEA 
          bgBkAGUAAACe 
          FYQBYwCjAaMA 
          owCGkoSWlgdO 
          U0NvbG9yhpKE 
          hIQHTlNDb2xv 
          cgCUowGEBGZm 
          ZmaD8/JyP4Pw 
          728/g+zraz8B 
          hoaG 
              </data> 
             </dict> 

回答

2

這是一個base64編碼的NSArchiver存檔。您需要首先解碼base64,然後使用[NSUnarchiver unarchiveObjectWithData:]。上面的「Dictionary」條目在解碼之後看起來像這樣(在Python語法中,因爲我使用了pyObjC):

{ 
    NSBackgroundColor = "NSCalibratedWhiteColorSpace 0 0"; 
    NSColor = "NSCalibratedRGBColorSpace 0.94902 0.937255 0.921569 1"; 
    NSExpansion = "0.1053606"; 
    NSFont = "\"LucidaGrande 21.00 pt. P [] (0x103110b60) fobj=0x103110c30, spc=6.64\""; 
    NSObliqueness = 0; 
    NSParagraphStyle = "Alignment 0, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0"; 
}