ASCII as default encoding!?

131 views
Skip to first unread message

k

unread,
Feb 21, 2010, 7:10:34 PM2/21/10
to nodejs
I'm shocked that response.write uses ASCII as the default encoding,
and actually enforces 7-bitness. To me this seems to be far worse
default than either utf8 (which is superset of ASCII after all) or
even encoding-ignorant 8-bit binary.

I'm wondering what's the reason for this default. Is it bug, omission?
A plan to break everyone's applications so badly that they'll never
forget to specify encoding explicitly, everywhere, every time?

Scott González

unread,
Feb 21, 2010, 9:11:13 PM2/21/10
to nod...@googlegroups.com
I think the decision was made based on speed. This is straight from the docs:

Node supports 3 string encodings. UTF-8 ("utf8"), ASCII ("ascii"), and Binary ("binary"). "ascii" and "binary" only look at the first 8 bits of the 16bit JavaScript string characters. Both are relatively fast—use them if you can. "utf8" is slower and should be avoided when possible.



--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.


CC

unread,
Feb 23, 2010, 7:58:02 AM2/23/10
to nod...@googlegroups.com
Why not utf-16 in the core like php 6 ?

After all, there is the default and the option. Which would be the
default, which would be the option. Php sends content so utf is the
default, but Node ?

In addition, their is the content and also the environnement. I'm
French so I write errors/logs in my langage, my urxvt terminal uses
unicode and that works fine with "coucou éé
@@34567890'(-è_çà'(-È_ÇÀ?/§%µ*tout a planté".

Slower, 3% ?

2010/2/22 Scott González <scott.g...@gmail.com>:

Message has been deleted

Joran Greef

unread,
Feb 23, 2010, 1:14:31 PM2/23/10
to nodejs
Would also prefer UTF8 as the default encoding since that is the most
common use-case in my code. On the occasion where it is known that the
data is ASCII, I would prefer to specify that explicitly.

Rob Crowther

unread,
Feb 23, 2010, 1:31:12 PM2/23/10
to nod...@googlegroups.com
I concur. If UTF-8 (or any Unicode variant) is slow, I think we should
focus on improving the performance, rather than having our apps patch
in support for what is pretty much a universal standard now.

On Tue, Feb 23, 2010 at 1:11 PM, Joran Greef <joran...@gmail.com> wrote:
> Would also prefer UTF-8 encoding to be the default since that is the
> option used throughout my code. I would rather specify ASCII
> explicitly since it's not the common use-case that my application's
> data is solely ASCII.


>
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
>

--
ヽ(^o^)ノ -rob

Alexander Teinum

unread,
Feb 23, 2010, 3:30:10 PM2/23/10
to nod...@googlegroups.com
Yup, another vote here for UTF-8.

Here is some statistics from Google on its usage:


-- 
Best regards,

Alexander Teinum
Reply all
Reply to author
Forward
0 new messages