Warwars
Warwars

Reputation: 11

Python does not let me print turkish characters

Even though i add a comment to change the encoding to utf-8 i get an error. I can not print ü ğ ş ç İ Ş Ç Ğ Ö Ü

# -*- coding: utf-8 -*-
print("ğ")

The error i get

SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xf0 in position 0: unexpected end of data

I am using virtual studio 2022 and Python 3.10 (i think the latest ?)

Upvotes: 0

Views: 1109

Answers (2)

Warwars
Warwars

Reputation: 11

The issue was not related to python or any code.

My command prompt window was not adjusted to utf-8. I changed it in the language settings. Thanks for your reply nonetheless sidereal !

Upvotes: 1

sidereal
sidereal

Reputation: 36

You need to use encoding='utf-8'

Have you read this question already? There are different unicodes for the Turkish language, you can 'decrypt' them by using the list of unicodes. Take a look at the link I provided

Upvotes: 0

Related Questions