Giter Club home page Giter Club logo

Comments (2)

hszhsh avatar hszhsh commented on July 19, 2024

你说的是这个吗
`/**

  • @en
  • Decode base64-compressed uuid.
  • @zh
  • 解码用 base64 压缩过的 uuid。
  • @param base64 @en Base-64 compressed uuid. @zh 用 base-64 压缩过的 uuid。
  • @returns @en Original uuid. @zh 未压缩过的 uuid。
  • @example
  • const uuid = 'fcmR3XADNLgJ1ByKhqcC5Z';
  • const originalUuid = decodeUuid(uuid); // fc991dd7-0033-4b80-9d41-c8a86a702e59

*/
export default function decodeUuid (base64: string): string {
const strs = base64.split(separator);
const uuid = strs[0];
if (uuid.length !== 22) {
return base64;
}
UuidTemplate[0] = base64[0];
UuidTemplate[1] = base64[1];
for (let i = 2, j = 2; i < 22; i += 2) {
const lhs = BASE64_VALUES[base64.charCodeAt(i)];
const rhs = BASE64_VALUES[base64.charCodeAt(i + 1)];
UuidTemplate[Indices[j++]] = HexChars[lhs >> 2];
UuidTemplate[Indices[j++]] = HexChars[((lhs & 3) << 2) | rhs >> 4];
UuidTemplate[Indices[j++]] = HexChars[rhs & 0xF];
}
return base64.replace(uuid, UuidTemplate.join(''));
}

if (TEST) {
legacyCC._Test.decodeUuid = decodeUuid;
}`

from cocos-engine.

finscn avatar finscn commented on July 19, 2024

你说的是这个吗 `/**

  • @en
  • Decode base64-compressed uuid.
  • @zh
  • 解码用 base64 压缩过的 uuid。
  • @param base64 @en Base-64 compressed uuid. @zh 用 base-64 压缩过的 uuid。
  • @returns @en Original uuid. @zh 未压缩过的 uuid。
  • @example
  • const uuid = 'fcmR3XADNLgJ1ByKhqcC5Z';
  • const originalUuid = decodeUuid(uuid); // fc991dd7-0033-4b80-9d41-c8a86a702e59

*/ export default function decodeUuid (base64: string): string { const strs = base64.split(separator); const uuid = strs[0]; if (uuid.length !== 22) { return base64; } UuidTemplate[0] = base64[0]; UuidTemplate[1] = base64[1]; for (let i = 2, j = 2; i < 22; i += 2) { const lhs = BASE64_VALUES[base64.charCodeAt(i)]; const rhs = BASE64_VALUES[base64.charCodeAt(i + 1)]; UuidTemplate[Indices[j++]] = HexChars[lhs >> 2]; UuidTemplate[Indices[j++]] = HexChars[((lhs & 3) << 2) | rhs >> 4]; UuidTemplate[Indices[j++]] = HexChars[rhs & 0xF]; } return base64.replace(uuid, UuidTemplate.join('')); }

if (TEST) { legacyCC._Test.decodeUuid = decodeUuid; }`

是这个, 但是这个是 decode , 我还想要 encode .

其实 uuid的压缩 解压 算法和 cocos 2.x 的是一样的. 我如果要用 可以自己从 cocos 2.x 里copy出来.
但是我还是希望引擎直接提供 . 因为万一哪天 3.x 改了算法呢. 还是引擎提供保险些.
(可以不开放出来, 但是最好能让开发者找到源码, 知道具体怎么处理的)

from cocos-engine.

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.