2024-08-17, 08:11 AM
(This post was last modified: 2024-08-17, 08:23 AM by Yababakets. Edited 3 times in total.)
(2023-06-30, 04:26 PM)adymaster Wrote: I have a problem with the subtitles. In stead of diacritics appear (?), Romania Country.
Haw I can Solve that?
Thanks
Hi, based on the previous posts, the issue you're encountering with the question mark (?) replacing diacritics (Ăă, Ââ, Îî, Șș, Țț) isn't related to fonts, clients, or similar factors. The problem arises because the subtitle's character encoding is set to Central European ISO-8859-2 (which covers Albanian , Bosnian , Croatian , Czech , Finnish , German , Hungarian , Polish , Romanian , Rotokas , Serbian , Slovak , Slovene ,Upper Sorbian , Lower Sorbian , Turkmen ) , whereas Jellyfin prefers Unicode UTF-8.
To resolve this, you can try the following methods:
- Use Gaupol (a subtitle editor):
- Install Gaupol on your system. You can download the Windows version from here.
- Open the subtitle file using the Central European (ISO-8859-2) character encoding.
- Save the file with the Unicode ( UTF-8 ) character encoding.
- Install Gaupol on your system. You can download the Windows version from here.
- Use an online converter:
- Visit an online encoding converter like FreeFormatter.
- Upload your subtitle file and convert it from ISO-8859-2 to UTF-8.
- Download the converted file. Note that this method might not successfully convert all characters.
- Visit an online encoding converter like FreeFormatter.
If you have a large number of subtitles, converting them individually could take a significant amount of time. Instead, you can create a Python script to automate the process. Here's how:
- Open a text file and add the following code:
Code:
import os
import codecs
# Function to check if a file is UTF-8 encoded
def is_utf8(file_path):
try:
with open(file_path, 'r', encoding='UTF-8') as f:
f.read()
return True
except UnicodeDecodeError:
return False
# Function to convert ISO-8859-2 to UTF-8
def convert_encoding(file_path):
with codecs.open(file_path, 'r', encoding='ISO-8859-2') as f:
content = f.read()
with codecs.open(file_path, 'w', encoding='UTF-8') as f:
f.write(content)
# Function to process directory
def process_directory(directory):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(('.sub', '.srt')):
file_path = os.path.join(root, file)
if not is_utf8(file_path):
convert_encoding(file_path)
print(f"Converted: {file_path}")
else:
print(f"Skipping: {file_path} (already UTF-8)")
# Main function
def main():
directory = r"C:\your\path" # Replace with the path to your folder containing the subtitles
process_directory(directory)
if __name__ == "__main__":
main()
- Save the file as iso2utf.py
- Replace "C:\your\path" with your path
- Ensure you have the latest version of Python installed to run the script.
You can run the script in Command Prompt (Windows) or Terminal (macOS/Linux). Alternatively, you can open it in Visual Studio Code and run it from there.
This script will automate the process of checking and converting subtitle files (formats .sub and .srt) from ISO-8859-2 to UTF-8 encoding.