Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:34:02+00:00 2026-06-08T18:34:02+00:00

I use process.stdin.setEncoding(‘utf8’); But when i listen a event ‘data’ , the text isn’t

  • 0

I use process.stdin.setEncoding('utf8');
But when i listen a event 'data', the text isn’t egal.

process.stdin.on('data', function (text) {
  if (text === 'q') console.log('ouiiiiiiiiii');
  else console.log(text);
});

I type ‘q’ but don’t display “ouiiiiiiiii”, and the text is q… but the text === 'q' is to false, why ? thanks

I think it’s due to the encoding, but i don’t know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:34:04+00:00Added an answer on June 8, 2026 at 6:34 pm

    First, call process.stdin.resume() before you setup your callback on stdin. Also, make sure to convert your text variable to a string, as I believe it’s a Buffer object.

    So, something like this should work:

    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    
    process.stdin.on('data', function (text) {
     if (text.toString().trim() === 'q') {
       console.log('ouiiiiiiiiii');
     } else {
       console.log(text.toString());
     }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I use Process.Start(), but have the launched process not in the same
I saw some code snippet like below: process.stdin.on('keypress', function(c, key){ if (key && 'enter'
I use process explorer (which is a microsoft tool) on windows XP, and often
When should I use process-wide dictionary and when should my process state be in
What is the use of process option in Analysis service Database,Cube,Dimension seperately?If we process
Which one to use for process monitoring and why?
i have application who use specific process during running and i want to sample
I use python to process web page. I download the souce code of the
Is it possible to use getopts to process multiple options together? For example, myscript
I thought that a 32-bit process could use at most 2GB RAM, since half

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.