Skip to content

Instantly share code, notes, and snippets.

@djromero
Created September 17, 2018 15:51
Show Gist options
  • Save djromero/362129531bf267bf0aef38e550a9bd5d to your computer and use it in GitHub Desktop.
Save djromero/362129531bf267bf0aef38e550a9bd5d to your computer and use it in GitHub Desktop.
Replace text in UTF-16 Little Endian
#!python2
import sys
import codecs
name_in = sys.argv[1]
name_out = sys.argv[2]
with open(name_in, "rb") as input:
data = input.read()
data = data.decode("utf-16-le")
data = data.replace(u"iPhone XS Max", u"iPhone\u00A02XS\u00A02Max") # non-breaking space
data = data.encode("utf-16-le")
with open(name_out, "wb") as output:
output.write(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment