Coder Social home page Coder Social logo

Comments (5)

AlexaDeWit avatar AlexaDeWit commented on July 24, 2024

Doing some investigating related to this...

It looks like fromCodePoint and codePointAt use the binary code point representation, which omits the "1101 1" leader bits.'

https://en.wikipedia.org/wiki/UTF-16#Examples

This means that to encode a complete string in a Uint16Array buffer, we're going to need to do the translation between that smaller binary space to the full 32 bits and then split them by byte pairs.

That is to say, we need to translate from this encoding:
"0001 0000 0100 0011 0111" 20 bits, to this encoding: "D801 DC37", 32 bits.

This is not a simple as a simple split and append however, as the first 10 bits may change during the translation. See the UTF-16 for better specifics.

from purescript-arraybuffer.

AlexaDeWit avatar AlexaDeWit commented on July 24, 2024

A little note to this, that way quickcheck reasons about strings, they are only generated in the first 65k form, so we don't have a truly comprehensive dataset without generating it for this.

from purescript-arraybuffer.

AlexaDeWit avatar AlexaDeWit commented on July 24, 2024

The polyfills can provide essentially most of the behaviour needed if extracting the relevant components.

To do this without risk of stack overflows and efficiently is likely going to involve mutation. If I get to writing it this weekend it will likely be implemented in JS I'm afraid, rather than via folds in purescript.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt

from purescript-arraybuffer.

AlexaDeWit avatar AlexaDeWit commented on July 24, 2024

I think it might actually be possible to use the lazy approach and make use of purescript-encoding with the polyfill. I will do an experiment once my PR to the encoding lib goes through to update it to 0.12.

The user seems inactive so I may start maintaining a fork if necessary, given that no contact details exist for them.

from purescript-arraybuffer.

AlexaDeWit avatar AlexaDeWit commented on July 24, 2024

I think we can effectively close this, as #17 is probably the upper limit of what we're going to get unless we do a total re-implementation.

from purescript-arraybuffer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.