I'm not even sure how to ask this properly but from my limited understanding of what standard input really is and the fact that:
There Ain’t No Such Thing As Plain Text. If you have a string, in memory, in a file, or in an email message, you have to know what encoding it is in or you cannot interpret it or display it to users correctly
Then I think this question makes sense: what is the default encoding of bash ?
In the context of a Node.js app listening for inputs from the user:
process.stdin
.pipe(through(chunk, _, next) {
console.log(chunk.toString()) // chunk is an instance of Buffer
next()
})
When launching this with node app.js and pressing the character a it's get decoded back correctly ("standard output" displays a), which according to the doc means that it's being decoded as a utf-8 encoded character (because it's the default of the toString() method).
Since utf8 is backward compatible with ascii, when I press the char a, it could be either ascii or utf8 (or any other ascii compatible encoding for that matter though i'm assuming it's unlikely). So this boils down to:
- Which program is responsible for encoding it (
terminal?bash?) - What encoding is it ?
ascii?utf8?
I'm so confused