Questions tagged [byte]

Typically consisting of 8 bits, a byte is commonly recognized as the smallest addressable unit of storage on digital devices.

Is it possible to transform an integer into half a byte using the `to_bytes()` method

Let's say I have a series of integers: var = [1, 5, 4, 17, 231, 89] If I wanted to transform these into bytes, I could use the following code: [(i).to_bytes(1, byteorder='big') for i in var] Since each number in var is under 256, it can be represented ...

Retrieve a byte array from ASP.NET controller class

I'm working on a Controller class (using C#) that needs to return a byte array from its login method. Below is the source code for my Login functionality within the Controller class: [RoutePrefix("Account")] public class AccountsController : ApiContro ...

Having an excess of 32 individual byte values

My current project involves developing a permission system using bitwise operators. A question came up regarding the limitation of having only 32 permissions in place: enum permissions { none = 0, Founder = 1 << 0, SeeAdmins = 1 << ...

Is a Chinese character typically represented by 4 bytes?

While attempting to understand this in PHP: $html = htmlentities("漢"); var_dump($html); The result shows, string(3) "漢", indicating 3 bytes? ...

Converting byte offsets in utf-8 to character offsets in utf-8

In need of assistance with post-processing the output from a legacy tool that provides UTF-8 byte offsets rather than character offsets. An example would be reporting [0, 1, 3, 4, 6] instead of [0, 1, 2, 3, 4] for the seven-byte UTF-8 string 'aβgδe', due ...

Transmitting encoded bytes data via JSON

Currently, I am developing a Python RESTful API and facing the challenge of transmitting bytes-encoded data (specifically encrypted data using a public RSA key from the rsa package) over the network in JSON format. This is what the scenario looks like: & ...

Utilizing AngularJS to Transmit Byte Arrays in Form Data to an API

My current challenge involves sending a byte array to an API alongside some field data, as depicted in the figure. I am hesitant to use modules from the AngularJS community because they do not provide clear information on how the data is transferred, and m ...

Determine the byte size of the ImageData Object

Snippet: // Generate a blank canvas let canvas = document.createElement('canvas'); canvas.width = 100; canvas.height = 100; document.body.appendChild(canvas); // Access the drawing context let ctx = canvas.getContext('2d'); // Extrac ...

Guide on creating a readUInt16BE function in a Node.js environment

Looking to implement the readUint16BE function in node.js, here's how it is declared: buf.readUInt16BE(offset, [noAssert]) Documentation: http://nodejs.org/api/buffer.html#buffer_buf_readuint16be_offset_noassert This function reads an unsigned 1 ...