Giter Club home page Giter Club logo

Comments (9)

samthor avatar samthor commented on June 4, 2024

Setting fatal=true will cause the polyfill to fail since it's not supported.

I could probably add support, it wouldn't be too hard.

from fast-text-encoding.

khoanguyen-yang avatar khoanguyen-yang commented on June 4, 2024

But it seems the fatal option is not used at all in the library

fatal is always set to false here https://github.com/samthor/fast-text-encoding/blob/master/src/o-decoder.js#L51
But the validation above it rejects the fatal option. https://github.com/samthor/fast-text-encoding/blob/master/src/o-decoder.js#L35
So wondering why you need the validation when you do not use it at all?


FYI, I am currently use your library to polyfill encoder/decoder in React Native and some other libraries do use the fatal option. I made a simple patch to disable only the validation (leaving this.fatal=false unchanged) and it seems to be working fine.
However I am not sure your library will work 100% ok for that change. So it would be nice if I have your confirmation or if you have time, you can make a change to the library if possible and necessary.

from fast-text-encoding.

pablodenadai avatar pablodenadai commented on June 4, 2024

Setting fatal=true will cause the polyfill to fail since it's not supported.
I could probably add support, it wouldn't be too hard.

That'd be awesome if you could add support for fatal. Otherwise please provide some guidance and I'll help implement it. Thanks!

from fast-text-encoding.

jupiterrosen avatar jupiterrosen commented on June 4, 2024

@pablodenadai @samthor @khoanguyen-yang I'm also encountering this issue when integrating with solanaweb3js

from fast-text-encoding.

krisgrm avatar krisgrm commented on June 4, 2024

yers please i need it also

from fast-text-encoding.

eduardhasanaj avatar eduardhasanaj commented on June 4, 2024

@samthor can you please let us know what is the status of this feature request?

from fast-text-encoding.

eduardhasanaj avatar eduardhasanaj commented on June 4, 2024

Till the pull request is approved you can use my branch

npm install github:eduardhasanaj/fast-text-encoding#add-fatal-option-support

from fast-text-encoding.

samthor avatar samthor commented on June 4, 2024

The PR #29 doesn't cover all cases, i.e., it will not detect invalid UTF-8:

  • it only covers one failure mode of UTF-8 encoding (it doesn't check continuation bytes) for the fallback code
  • it doesn't support Node (Buffer does not throw, it generates U+FFFD characters for invalid input)

for folks on the thread, the two questions you need to ask are:

  • do you actually want UTF-8 validation, or do you just have some upstream library that expects fatal to be supported
  • why do you want this at all: modern Node and browsers do not need this polyfill (I wrote it in 2017!), and I'd go as far as saying including it is actively harmful.

from fast-text-encoding.

eduardhasanaj avatar eduardhasanaj commented on June 4, 2024

@samthor I agree that #29 does not cover all cases on detecting invalid utf-8 for the reasons you mentioned.

  1. Some upstream library expects fatal mode to be supported.
  2. I nedd this polyfill in React Native.

from fast-text-encoding.

Related Issues (13)

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.