Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

297
Vistas
How to remove null bytes from Javascript strings

Given a table, when the user selects a row I save the values of that row in an array.

Code:

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
})

For some reason, inner_array contains unwanted characters such as the byte: "b'\x00'"

These characters cause me problems on the back-end as python interprets backslash as a special character.

How could I get rid of those unwanted byte characters?

For example, instead of pushing that byte, I would like to push an empty string (pseudo):

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

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Just replace them before

It is also more DRY

const text = $(this).text().trim().replace(/b'\\x00'/g,"")
inner_array.push($.isNumeric(text) ? Number(text) : text)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda