+6

How to take unicode input here on Sololearn?

There are solutions for printing unicode letters like ü in our Sololearn console codes. But what do we do with user input? Whenever I input() German umlauts, I get an error.

10/9/2019 8:47:17 PM

HonFu

12 Answers

New Answer

+4

HonFu With difficulty. I recently made a code using unicode in C++. Later helped someone generate Farsi characters in Python. It took time to find a method and format that worked. Examples: Python: https://code.sololearn.com/cNtlKBbnBQPn/?ref=app C++: https://code.sololearn.com/c5z7Wfic8yWU/?ref=app

+4

Hm, interesting (I don't really get it). So no easy way around this? Why is this even a problem? Shouldn't Sololearn's PC's be able to process unicode voluntarily?

+3

A few minutes to make a sample. The C++ example does not need the parameter pack.

+2

HonFu Who knows. The non web codes, do not work like they do in IDEs.

+2

Hm, but how can you make use of that with input which seems to come as str? 🤔

+2

HonFu I currently would not make a project with unicode input. If the input is critical, I feel the result may not be good.

+2

Can you post a MWE? My keyboard is Spanish/English so I don't run into troubles.

+1

Thank you for waiting since you needed a python version. Python: https://code.sololearn.com/clG1q5b5nIr9/?ref=app

+1

HonFu Unfortunatly I do not know how it works, yet. I found mixed answers online. C++ version: https://code.sololearn.com/c8UOZ3E0s3HL/?ref=app

+1

You can try "\U" or "\u" before the string. Both will help. But the first one is for 16 bit hexadecimal value and the second one is for 16 bit hexadecimal value. And it's a python function.

+1

Diego import sys, codecs sys.stdout = codecs.getwriter('utf-16')(sys.stdout.buffer, 'strict') print('ü') print(input()) # input 'ü' Without the encoding lines, only one line works; outcomment them, suddenly only the other works.

0