11#include " encoding_binding.h"
22#include " ada.h"
33#include " env-inl.h"
4- #include " node_buffer.h"
54#include " node_errors.h"
65#include " node_external_reference.h"
76#include " simdutf.h"
@@ -221,7 +220,6 @@ void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
221220 SetMethodNoSideEffect (isolate, target, " decodeUTF8" , DecodeUTF8);
222221 SetMethodNoSideEffect (isolate, target, " toASCII" , ToASCII);
223222 SetMethodNoSideEffect (isolate, target, " toUnicode" , ToUnicode);
224- SetMethodNoSideEffect (isolate, target, " decodeLatin1" , DecodeLatin1);
225223}
226224
227225void BindingData::CreatePerContextProperties (Local<Object> target,
@@ -239,53 +237,6 @@ void BindingData::RegisterTimerExternalReferences(
239237 registry->Register (DecodeUTF8);
240238 registry->Register (ToASCII);
241239 registry->Register (ToUnicode);
242- registry->Register (DecodeLatin1);
243- }
244-
245- void BindingData::DecodeLatin1 (const FunctionCallbackInfo<Value>& args) {
246- Environment* env = Environment::GetCurrent (args);
247-
248- CHECK_GE (args.Length (), 1 );
249- if (!(args[0 ]->IsArrayBuffer () || args[0 ]->IsSharedArrayBuffer () ||
250- args[0 ]->IsArrayBufferView ())) {
251- return node::THROW_ERR_INVALID_ARG_TYPE (
252- env->isolate (),
253- " The \" input\" argument must be an instance of ArrayBuffer, "
254- " SharedArrayBuffer, or ArrayBufferView." );
255- }
256-
257- bool ignore_bom = args[1 ]->IsTrue ();
258- bool has_fatal = args[2 ]->IsTrue ();
259-
260- ArrayBufferViewContents<uint8_t > buffer (args[0 ]);
261- const uint8_t * data = buffer.data ();
262- size_t length = buffer.length ();
263-
264- if (ignore_bom && length > 0 && data[0 ] == 0xFF ) {
265- data++;
266- length--;
267- }
268-
269- if (length == 0 ) {
270- return args.GetReturnValue ().SetEmptyString ();
271- }
272-
273- std::string result (length * 2 , ' \0 ' );
274-
275- size_t written = simdutf::convert_latin1_to_utf8 (
276- reinterpret_cast <const char *>(data), length, result.data ());
277-
278- if (has_fatal && written == 0 ) {
279- return node::THROW_ERR_ENCODING_INVALID_ENCODED_DATA (
280- env->isolate (), " The encoded data was not valid for encoding latin1" );
281- }
282-
283- std::string_view view (result.c_str (), written);
284-
285- Local<Value> ret;
286- if (ToV8Value (env->context (), view, env->isolate ()).ToLocal (&ret)) {
287- args.GetReturnValue ().Set (ret);
288- }
289240}
290241
291242} // namespace encoding_binding
0 commit comments