(self, source, dest)
Copies a .strings file using iconv to reconvert the input into UTF-16.
Copies a .strings file using iconv to reconvert the input into UTF-16.
Copies a . strings file using iconv to reconvert the input into UTF - 16 .
def _CopyStringsFile(self, source, dest):
        """Copies a .strings file using iconv to reconvert the input into UTF-16."""
        input_code = self._DetectInputEncoding(source) or "UTF-8"

        # Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call
        # CFPropertyListCreateFromXMLData() behind the scenes; at least it prints
        #     CFPropertyListCreateFromXMLData(): Old-style plist parser: missing
        #     semicolon in dictionary.
        # on invalid files. Do the same kind of validation.
        import CoreFoundation

        with open(source, "rb") as in_file:
            s = in_file.read()
        d = CoreFoundation.CFDataCreate(None, s, len(s))
        _, error = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None)
        if error:
            return

        with open(dest, "wb") as fp:
            fp.write(s.decode(input_code).encode("UTF-16"))
def _CopyStringsFile ( self , source , dest ) : input_code = self . _DetectInputEncoding ( source ) or "UTF-8" # Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call # CFPropertyListCreateFromXMLData() behind the scenes; at least it prints #     CFPropertyListCreateFromXMLData(): Old-style plist parser: missing #     semicolon in dictionary. # on invalid files. Do the same kind of validation. import CoreFoundation with open ( source , "rb" ) as in_file : s = in_file . read ( ) d = CoreFoundation . CFDataCreate ( None , s , len ( s ) ) _ , error = CoreFoundation . CFPropertyListCreateFromXMLData ( None , d , 0 , None ) if error : return with open ( dest , "wb" ) as fp : fp . write ( s . decode ( input_code ) . encode ( "UTF-16" ) )