Oh.. things are more simple than I supposed!
Thank's, Dan! You saved my brain
четверг, 2 августа 2012 г., 17:24:57 UTC+4 пользователь Dan Milon написал:
>
> for me, text is "exit\n"
> I guess you are on windows, so text is "exit\r\n"
>
> The readline module might help you.
>
> On 08/02/2012 04:15 PM, Danil Gazizov wrote:
> > I'm confused of how to compare string const with variable.
> > Look at this simple example where keyboard input compares with const
> > string.
> > I suggest this is encoding problem. Please, tell me what should be
> > done to exit process ?
> > File encoding is utf8
> >
> > process.stdin.setEncoding();//default is utf-8
> > process.stdin.resume();
> > process.stdin.on("data", function(text) {
> >
> > //shows entered length=*6*
> > console.log('entered length=' + text.length);
> >
> > //shows compare length=*4*
> > console.log('compare length=' + 'exit'.length);
> >
> > if (text == 'exit'){
> > //never works
> > console.log('matched!');
> > }
> > });
> >
> > --
> > Job Board: http://jobs.nodejs.org/
> > Posting guidelines:
> > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> > You received this message because you are subscribed to the Google
> > Groups "nodejs" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> > http://groups.google.com/group/nodejs?hl=en?hl=en
>
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en