gp_inf: Read/write files with a UTF-16LE BOM in GptTmpl.inf
[samba.git] / python / samba / gp_parse / gp_inf.py
index 79e28159f1f09e2283621df19581a7babd88e98f..a3c828fa82d34bc17868fa6cb5edce2d0e125142 100644 (file)
@@ -29,11 +29,11 @@ from samba.gp_parse import GPParser
 # [MS-GPSB] Security Protocol Extension
 class GptTmplInfParser(GPParser):
     sections = None
-    encoding = 'utf-16le'
+    encoding = 'utf-16'
+    output_encoding = 'utf-16le'
 
     class AbstractParam:
         __metaclass__ = ABCMeta
-        encoding = 'utf-16le'
 
         def __init__(self):
             self.param_list = []
@@ -333,7 +333,10 @@ class GptTmplInfParser(GPParser):
 
     def write_binary(self, filename):
         with codecs.open(filename, 'wb+',
-                         self.encoding) as f:
+                         self.output_encoding) as f:
+            # Write the byte-order mark
+            f.write(u'\ufeff')
+
             for s in self.sections:
                 self.sections[s].write_section(s, f)