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

308
Vistas
JS Bytes, strings, raw convert

I have a working Python code that send/receive messages by websocket. I had copied the message (prepared to be sending):

\x00\x00U\xaa\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00x\xef\x80n\x14\x90\xdc2Qm9\xc0\xd0gTD\xd9\x9f%\xfa «w\xbd\xec\xf2\xec`\xf9\x84\x8cVFL\x16\xa6K\xd8\xe2\xbf$\x8b\xd5P\xa3\xbb\x0c\xe6\xaa\xd5\xd6\x81F\x96\xfd\xc7E\x88\x9b\xdf(\x87.\x1d\x00E\x9a%4XT\xa0\xf9d\xaf\n\xd2\xe3\xc6\x86\x02\xbc\x19V=\xd8\x8a[\xf7\xdb\xbdN\x1a\xbe\xee/\xc7\x10\xa3\xf3\x02\x016\x13g}\t=\xda\xdc~\xa9\xd0\x91\xc9\x0e\x93\x00\x00\xaaU

Now I try to send it from javascript. How I can send it? Cause it's string, but I need to send as raw bytes.

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

0

Conversion to a typed array:

let data = '\x00\x00U\xaa\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00x\xef\x80n\x14\x90\xdc2Qm9\xc0\xd0gTD\xd9\x9f%\xfa «w\xbd\xec\xf2\xec`\xf9\x84\x8cVFL\x16\xa6K\xd8\xe2\xbf$\x8b\xd5P\xa3\xbb\x0c\xe6\xaa\xd5\xd6\x81F\x96\xfd\xc7E\x88\x9b\xdf(\x87.\x1d\x00E\x9a%4XT\xa0\xf9d\xaf\n\xd2\xe3\xc6\x86\x02\xbc\x19V=\xd8\x8a[\xf7\xdb\xbdN\x1a\xbe\xee/\xc7\x10\xa3\xf3\x02\x016\x13g}\t=\xda\xdc~\xa9\xd0\x91\xc9\x0e\x93\x00\x00\xaaU'
let typedArray = Uint8Array.from(data, e => e.charCodeAt(0) );

Here, e => e.charCodeAt(0) is used to convert '\x00' to 0 , 'U' to 85, etc.

And assuming you use a have a plain web socket object let socket,

socket.send(typedArray)
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