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

  • Home
  • SEARCH
  • 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 6614643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:21:49+00:00 2026-05-25T20:21:49+00:00

printargv.js: console.log(Buffer.byteLength(process.argv[2])); In cmd.exe (with chcp=65001,font=’Lucida Console’), I ran: node printargv.js Ā (Note: unicode

  • 0

printargv.js:

console.log(Buffer.byteLength(process.argv[2]));

In cmd.exe (with chcp=65001,font=’Lucida Console’), I ran:

node printargv.js Ā 

(Note: unicode code point of Ā is U+0100.) The script outputted:

1

I expected the script to print a number greater than 1 but it doesn’t. Does anyone know why?

edit:
i think that node ‘parses’ initial arguments incorrectly for cmd.exe after i tried the below code:

var i = require('readline').createInterface(process.stdin,process.stdout);

i.question('char: ', function(c){
  console.log( Buffer.byteLength(c) );
  i.close();
  process.stdin.destroy();
});

the output is 2

  • 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-05-25T20:21:50+00:00Added an answer on May 25, 2026 at 8:21 pm

    Your program is not receiving the Ā, it’s receiving an A instead. I used this program to test:

    var n;
    for (n = 0; n < process.argv.length; ++n) {
        console.log(n + ": '" + process.argv[n] + "'");
    }
    console.log("length: " + process.argv[2].length);
    console.log("code: " + process.argv[2].charCodeAt(0));
    console.log("size: " + Buffer.byteLength(process.argv[2]));
    

    On Ubuntu using UTF-8 in the console, I got:

    $ node test.js Ā
    0: 'node'
    1: '/home/tjc/temp/test.js'
    2: 'Ā'
    length: 1
    code: 256
    size: 2

    …which is correct.

    On Windows 7 using chcp 65001 and Lucida Console, I got:

    C:\tmp>node temp.js Ā
    0: 'node'
    1: 'C:\tmp\temp.js'
    2: 'A'
    length: 1
    code: 65
    size: 1

    Note that the Ā became an A at some point along the way.

    As I said in my comment on the question, I can only assume there’s some issue with Lucida Console, or cmd.exe’s handling of UTF-8, or perhaps node.exe‘s handling of Unicode from the console on Windows (I used the pre-built 0.5.7 version).


    Update: This might be something to take up with the NodeJS folks, since Windows appears to get it right on its own. If I put this code in a test.vbs file:

    WScript.Echo WScript.Arguments(0)
    WScript.Echo AscW(WScript.Arguments(0))
    

    I get a correct result:

    C:\tmp>cscript /nologo test.vbs Ā
    Ā
    256

    …suggesting that the terminal is passing the argument correctly to the program. So it could be an issue with the Windows node.exe build.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my test.pl script as below. #!C:\Perl\bin\perl.exe use strict; use warnings; sub printargs { print
I have a working perl script that grabs the data I need and displays
I have a Python script and I want to call it several functions down
I am trying to get three arguments from command line: -o (for outputfile) -k
I wrote a function called strlen: .section .text .global strlen .type strlen, @function strlen:
I've run into Java code similar to the following: public interface BaseArg { }
When i am trying to print an image to a printer for a 700kb
I'm doing some assignment and got stuck at one point here. I am trying
Where do you check if an object that you are passing to a method
I have a string with possible command line arguments (using an Read-Eval-Print-Loop program) and

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.