Batch Convert XCode String files, from utf-16 to utf-8


Old Version Xcode create utf-16 string file. It is not easy to diff changes.


Batch convert string files from utf-16 to utf-8.


def convert(file_path: str, from_encoding: str, to_encoding: str):
utf16_path = file_path
utf8_tmp_path = utf16_path + ".tmp"
encoding=from_encoding) as input_file:
utf8_tmp_path, "w",
encoding=to_encoding) as output_file:
shutil.copyfileobj(input_file, output_file)
shutil.move(utf8_tmp_path, utf16_path)
return True
except Exception as e:
# ori file maybe not from_encoding.
return False
def batch_convert(dir_path: str):
for file in glob.glob("**/*.strings", recursive=True):
file_full_path = os.path.join(dir_path, file)
convert(file_path=file_full_path, from_encoding="utf-16", to_encoding="utf-8")


Easy to review diff in xcode string files.

Related Information




iOS App Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Machine Learning as a Service (MLaaS) is the Next Trend No One is Talking About

Redis in Ruby — Chapter 1 — A basic TCP server

FindFurryFriend Project — dotenv Ruby Gem

Button Loader in Xamarin Forms

Django Login/Registration System

Convince Your Team to Try Liquibase

Introducing Galaxy Professional & Built-in APM

A crash course on floating point numbers in a computer, Part I

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


iOS App Engineer

More from Medium

iOS | CI on fastlane and github actions [1]

Swift Concurrency

👾 Apollo Integration Fun on iOS

Unit Testing in Swift using (MVVM and RX)