Giter VIP home page Giter VIP logo

Comments (3)

sinclairzx81 avatar sinclairzx81 commented on July 18, 2024

@matlin Hi, Thanks for reporting.

This issue has been resolved in more recent versions of TypeBox. The current implementation as of 0.32.15 (current) is specified as:

Hash-NumberToBytes: https://github.com/sinclairzx81/typebox/blob/master/src/value/hash/hash.ts#L68
Hash-StringType: https://github.com/sinclairzx81/typebox/blob/master/src/value/hash/hash.ts#L115

function* NumberToBytes(value: number): IterableIterator<number> {
  const byteCount = value === 0 ? 1 : Math.ceil(Math.floor(Math.log2(value) + 1) / 8)
  for (let i = 0; i < byteCount; i++) {
    yield (value >> (8 * (byteCount - 1 - i))) & 0xff
  }
}
// ...
function StringType(value: string) {
  FNV1A64(ByteMarker.String)
  for (let i = 0; i < value.length; i++) {
    for (const byte of NumberToBytes(value.charCodeAt(i))) {
      FNV1A64(byte)
    }
  }
}

Looking back, this issue appears to have been resolved on 0.31.15 (#594) as the nearest version. If you upgrade to at least 0.31.15, things should be fixed.

Hope this helps!
S

from typebox.

sinclairzx81 avatar sinclairzx81 commented on July 18, 2024

Will close off as this issue as Unicode support for Hash has been implemented.

Cheers!

from typebox.

matlin avatar matlin commented on July 18, 2024

Thanks! Apologies - thought we were on the latest version!

from typebox.

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.