Git Product home page Git Product logo

Comments (6)

ShaneOH avatar ShaneOH commented on July 19, 2024 1

Just want to bump here that I had the same issue with MongoDB here and maybe it's related to those "invalid" UTF-16 characters. Switching compress to compressToUTF16 and same for decompress fixed this for me

from lz-string.

pieroxy avatar pieroxy commented on July 19, 2024

First, have a look at this (very similar) issue which could probably solve your problem: [https://github.com//issues/57]

lz-string is a hack that consists in storing binary data in a String. I only produce valid UTF-16 but maybe a text field in MongoDB is not accepting ALL characters.

The best way to troubleshoot is to compare the string you're storing to the string you're retrieving. My guess is that they are different in some way. Some UTF processing replaces characters with others deemed "equivalent". Of course, since lz-strnig uses it as a bitstream, it destroys the input.

from lz-string.

eisneim avatar eisneim commented on July 19, 2024

@pieroxy thanks

from lz-string.

tracker1 avatar tracker1 commented on July 19, 2024

It might be worth filing an issue with the mongo driver you're using, it's likely that the strings are being normalized (as @pieroxy mentioned) many characters can have multiple representations, and this may be a path taken to improve indexability.

Also, mongodb as of 3.0 supports compression, including zlib at the database level, so you should probably just store it from the buffer as a blob/binary... IIRC the node mongo interface should handle Buffer's

from lz-string.

eisneim avatar eisneim commented on July 19, 2024

thanks for your info @tracker1

from lz-string.

pieroxy avatar pieroxy commented on July 19, 2024

As the documentation states, compress and decompress produces invalid UTF-16 strings, so there is no guarantee a storage system will output its input unchanged.

from lz-string.

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.