Merge pull request #21227 from sbwilson:fix_framework_unicode_headers

* fix unicode errors for framework headers

This would crash if the header file included non-ASCII characters. This change ensures that headers are read and written as UTF-8 encoded files instead of ascii.

* Adds spaces after commas
pull/21238/head
Simon Wilson 3 years ago committed by GitHub
parent 7ba56a4b88
commit c08954c18b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      platforms/ios/build_framework.py

@ -406,11 +406,11 @@ class Builder:
for dirname, dirs, files in os.walk(os.path.join(dstdir, "Headers")):
for filename in files:
filepath = os.path.join(dirname, filename)
with open(filepath) as file:
with codecs.open(filepath, "r", "utf-8") as file:
body = file.read()
body = body.replace("include \"opencv2/", "include \"" + name + "/")
body = body.replace("include <opencv2/", "include <" + name + "/")
with open(filepath, "w") as file:
with codecs.open(filepath, "w", "utf-8") as file:
file.write(body)
if self.build_objc_wrapper:
copy_tree(os.path.join(builddirs[0], "install", "lib", name + ".framework", "Headers"), os.path.join(dstdir, "Headers"))

Loading…
Cancel
Save