Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for node::Encode/DecodeBytes/DecodeWrite #250

Closed
royaltm opened this issue Jan 19, 2015 · 6 comments
Closed

Add support for node::Encode/DecodeBytes/DecodeWrite #250

royaltm opened this issue Jan 19, 2015 · 6 comments

Comments

@royaltm
Copy link

royaltm commented Jan 19, 2015

Could you add support for those handy utils?

#if NODE_VERSION_AT_LEAST(0,11,12)
#define NanEncode(buf, buflen, encoding) \
  node::Encode(v8::Isolate::GetCurrent(), buf, buflen, encoding)
#define NanDecodeBytes(val, encoding) \
  node::DecodeBytes(v8::Isolate::GetCurrent(), val, encoding)
#define NanDecodeWrite(buf, buflen, val, encoding) \
  node::DecodeWrite(v8::Isolate::GetCurrent(), buf, buflen, val, encoding)
#else
#define NanEncode(buf, buflen, encoding) \
  node::Encode(buf, buflen, encoding)
#define NanDecodeBytes(val, encoding) \
  node::DecodeBytes(val, encoding)
#define NanDecodeWrite(buf, buflen, val, encoding) \
  node::DecodeWrite(buf, buflen, val, encoding)
#endif
@kkoopa
Copy link
Collaborator

kkoopa commented Jan 19, 2015

Probably. Were they around in Node 0.8?

On January 19, 2015 12:37:22 PM EET, royal [email protected] wrote:

Could you add support for those handy utils?

#if NODE_VERSION_AT_LEAST(0,11,12)
#define NanEncode(buf, buflen, encoding) \
 node::Encode(v8::Isolate::GetCurrent(), buf, buflen, encoding)
#define NanDecodeBytes(val, encoding) \
 node::DecodeBytes(v8::Isolate::GetCurrent(), val, encoding)
#define NanDecodeWrite(buf, buflen, val, encoding) \
node::DecodeWrite(v8::Isolate::GetCurrent(), buf, buflen, val,
encoding)
#else
#define NanEncode(buf, buflen, encoding) \
 node::Encode(buf, buflen, encoding)
#define NanDecodeBytes(val, encoding) \
 node::DecodeBytes(v8::Isolate::GetCurrent(), val, encoding)
#define NanDecodeWrite(buf, buflen, val, encoding) \
 node::DecodeWrite(buf, buflen, val, encoding)
#endif

Reply to this email directly or view it on GitHub:
#250

@bnoordhuis
Copy link
Member

Yes. All three have been around since the dawn of time (or node v0.3, whatever came first.)

@kkoopa
Copy link
Collaborator

kkoopa commented Jan 19, 2015

Only problem seems to be that 0.8 does not support the BUFFER encoding. Backporting is feasible.

@royaltm
Copy link
Author

royaltm commented Jan 19, 2015

Is really backporting an issue here? I'm using those to provide compatibility of
F(string, encoding) -> binary
G(binary, encoding) -> string
as in new Buffer(string, encoding), or buffer.toString(encoding).
So if particular version of node doesn't support some encoding, why otherwise it should? Unless you want to polyfill all native string+encoding functions.

@kkoopa
Copy link
Collaborator

kkoopa commented Jan 19, 2015

See #251.

@royaltm
Copy link
Author

royaltm commented Jan 19, 2015

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants