'Terminal not able to display UTF-8 correctly - ex.23 LPTHW

I'm a complete beginner and I'm trying to learn some Python using the book LPTHW by Zed A. Shaw. At the moment I'm at ex.23 of the book, and it seems the goal is to show the reader how to decode and encode letters in different languages. Here's the code I wrote:

import sys
script, input_encoding, error = sys.argv

def main(language_file, encoding, errors):
    line = language_file.readline()

    if line:
        print_line(line, encoding, errors)
        return main(language_file, encoding, errors)

def print_line(line, encoding, errors):
    next_lang = line.strip()
    raw_bytes = next_lang.encode(encoding, errors=errors)
    cooked_string = raw_bytes.decode(encoding, errors=errors)

    print(raw_bytes, "<===>", cooked_string)


languages = open("languages.txt", encoding="utf-8") # Unicode Transformation-8-bit

main(languages, input_encoding, error)

Here's a screenshot of the output on the Terminal when I run the code: Code output on CMD

That is not all the output of the code, it is too long to be able to take a screenshot, but you get the idea. On some languages I get some kind of strange question marks, can someone explain me why and how can I fix that? Again I'm a beginner so I apologize if I said some names wrong or didn't explain myself.

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source