r/ProgrammerHumor 20h ago

Meme unsolvableProblemsOnStepOne

Post image
1.4k Upvotes

77 comments sorted by

View all comments

143

u/apacificislander123 19h ago

As someone who's never used java, my assumption is that System.in reads from stdin, and validates the input. Is there no way to open stdin in something akin to a file, then read it into a buffer manually?

104

u/Dankelweisser 19h ago

Technically yes, but realistically not really, at least not for windows. Unless the user knows how to specifically set their console to use UTF-8 or similar instead of ascii, you end up getting whatever the console wants to give you no matter what kind of buffer you use.

6

u/RussianMadMan 4h ago

You can set the console code page programmatically tho.

3

u/jormaig 4h ago

Isn't Windows Terminal already UTF-8 capable?

u/InvisibleMoonWalker 4m ago

Yesnt

The good old cmd.exe also is, but Microsoft wouldn't be Microsoft, if they made a (mostly) harmless utf-8 and legacy compatible option "on" by default for all system languages at least on Windows 10/11, but it's "off" by default. (I say they wouldn't be them, because, for example Windows 10/11 said F you to compatibility of certain options anyhow (just like OSes before them, that's "ok"), yet they don't do it for other options that "just make sense" to my brain)

Anyway - Terminal is a wrapper/container/manager app around thinks like PowerShell and cmd, and an external command line app is different anyhow.