Skip to content

Instantly share code, notes, and snippets.

@DavideViolante
Created June 10, 2024 15:23
Show Gist options
  • Save DavideViolante/4ca6514f9f571f35fd36d4bc702ce9e3 to your computer and use it in GitHub Desktop.
Save DavideViolante/4ca6514f9f571f35fd36d4bc702ce9e3 to your computer and use it in GitHub Desktop.
# Python script to convert Shift-JIS encoded .srt file to UTF-8 - Powered by ChatGPT
# The issue you're encountering is likely due to an encoding problem.
# The text in your subtitle file seems to be encoded in Shift-JIS, a common encoding for Japanese text, but it is being interpreted incorrectly, probably as Latin-1 or another encoding.
# To fix this, you need to convert the subtitle file from Shift-JIS to UTF-8, which is the standard encoding for most modern software and supports a wide range of characters, including Japanese.
# Uou can use a simple Python script to convert the file from Shift-JIS to UTF-8. Here is a script that will do that for you:
input_file = 'input.srt' # Replace with your actual file name
output_file = 'output_utf8.srt' # Output file name
with open(input_file, 'r', encoding='shift_jis') as file:
content = file.read()
with open(output_file, 'w', encoding='utf-8') as file:
file.write(content)
print(f"File has been converted and saved as {output_file}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment