I have taken look at the MongoDB Shell source code in Github:
I have found out that MongoDB Shell have built in terminal device on which the user enters a stream of data and it manage cursor position etc ( using linenoise that is a readline replacement ) . It read a keystroke from the keyboard and translate it using the function readUnicodeCharacter to get Unicode (UChar32) character.
Why usage of simple code with scanf instead of custom console terminal is not good enough?
printf(“Enter somthing: “);
printf(“text = %s”,text);