| 2437 | |
| 2438 | #if NODE_MAJOR_VERSION >= 24 |
| 2439 | inline MaybeLocal<v8::Value> TryEncode( |
| 2440 | const void *buf, size_t len, enum Encoding encoding = BINARY) { |
| 2441 | v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 2442 | node::encoding node_enc = static_cast<node::encoding>(encoding); |
| 2443 | |
| 2444 | if (encoding == UCS2) { |
| 2445 | return node::TryEncode( |
| 2446 | isolate |
| 2447 | , reinterpret_cast<const uint16_t *>(buf) |
| 2448 | , len / 2); |
| 2449 | } else { |
| 2450 | return node::TryEncode( |
| 2451 | isolate |
| 2452 | , reinterpret_cast<const char *>(buf) |
| 2453 | , len |
| 2454 | , node_enc); |
| 2455 | } |
| 2456 | } |
| 2457 | |
| 2458 | inline v8::Local<v8::Value> Encode( |
| 2459 | const void *buf, size_t len, enum Encoding encoding = BINARY) { |