Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

296
Views
Cómo eliminar bytes nulos de cadenas de Javascript

Dada una tabla, cuando el usuario selecciona una fila, guardo los valores de esa fila en una matriz.

Código:

 var outer_array = [] //loop through checked checkboxes $("tbody input[type=checkbox]:checked").each(function(index, item) { var inner_array = [] var selector = $(this).closest("tr") //get closest tr //loop through trs td not first one selector.find("td:not(:first)").each(function() { inner_array.push($.isNumeric($(this).text().trim()) ? Number($(this).text().trim()) : $(this).text().trim()) //push in inner array }) outer_array.push(inner_array) //push in outer array })

Por alguna razón, inner_array contiene caracteres no deseados como el byte: "b'\x00'"

Estos caracteres me causan problemas en el back-end ya que Python interpreta la barra invertida como un carácter especial.

¿Cómo podría deshacerme de esos caracteres de bytes no deseados?

Por ejemplo, en lugar de enviar ese byte, me gustaría enviar una cadena vacía (pseudo):

 if (byte_code){ innter_array.push('') } else { inner_array.push($.isNumeric($(this).text().trim()) ? Number($(this).text().trim()) : $(this).text().trim()); }

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solo reemplácelos antes

También es más SECO

 const text = $(this).text().trim().replace(/b'\\x00'/g,"") inner_array.push($.isNumeric(text) ? Number(text) : text)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!