0

I have gotten the Cryllic alphabet to appear properly during script output, but typing into the terminal always appears in ASCII. Is there a way for a user to input Cryllic for storing as a string? below is some example code.

var = input(str)
    varB = var.lower()
    if varB == "да":

user inputs "Да", but console shows "da", causing boolean to return False

jdehesa
  • 58,456
  • 7
  • 77
  • 121

1 Answers1

-1

You must set the encoding of your python file as utf-8.

This can be done putting the following string on the top of the script file:

# -*- coding: utf-8 -*-

You can found more about it here on the docs or on this answer

Gustavo Lopes
  • 3,794
  • 4
  • 17
  • 57
  • I'm referring to user input into the terminal. Encoding is already there, but for example, when using ".input" the user input does not even show the Cryllic, only the Latin alphabet. Before it is even sent through the code. Imagine typing something into google, but every key press outputs Arabic instead of English, before you even search. Everywhere else my keyboard is outputting Cryllic including the script, just the terminal shows English – dark matter 48 May 22 '19 at 15:11
  • Which python are you using? Using python 3.6, I can run this simple snipet: `my_input = input('enter text: ') # input: д print(my_input) # prints д print(my_input.lower()) # also prints д ` But the character is a copy and paste. Maybe the problem is when entering the character in the terminal, describing a problem IN the terminal, not on your code. Although I tested with other non-ascii characters and worked like a charm. – Gustavo Lopes May 22 '19 at 16:40
  • The issue is not with output. Your code works fine. The issue is: User attempts to enter "ж" but "K" is outputted by the user. The user input appears on terminal as an ASCII character regardless of which letter is entered. Typing into Google output: "для" same keystrokes but into terminal outputs:"jhz" – dark matter 48 May 30 '19 at 01:00