format - 猜测数据类型
问题描述
我目前尝试猜测以下原始字节具有什么数据类型。
25B3 E548 0200 0000 0003 BF1F D44B 217C 5440 B64E 74B6 E16B 5A40 8B54 F861 F2A9 5440 68C3 95DF C88A 5A40 1021 9EB2 16D6 5440 374D 0D3C FBAB 5A40 01C2 1815 6400 5540 D628 2EA3 4ECF 5A40
它保存在一个名为 outlinePath 的变量中,并且与形状有关。原始字节使用 NSKeyedArchiver 以 base64 编码。
我已经尝试过 float32 数组和 int16。但是,两者都没有意义。
这是我想出的代码。此代码在数据集的其他部分工作正常:
/**
* Convert the base64 encoded float32 array to actually float32 values
* @param buffer base64 encoded string
*/
export function convertBase64Floats(buffer: string) {
// Decode base64
const decodedBuffer = new Buffer(buffer, 'base64');
// Float32 => 4 bytes
// Get number of float values
const floatValuesCount = decodedBuffer.length / 4;
// New array with correct floats
const arrayOfFloats: number[] = [];
// Get float32s from buffer
for (let i = 0; i < floatValuesCount; i++) {
const offset = i * 4;
const float = decodedBuffer.readFloatLE(offset);
arrayOfFloats.push(float);
}
// Return new array of correct float values
return arrayOfFloats;
}
export function convertInt32Array(buffer: Buffer, useBE: boolean = false) {
const intValuesCount = buffer.length / 4;
const arrayOfInts: number[] = [];
for (let i = 0; i < intValuesCount; i++) {
const offset = i * 4;
const float = useBE ? buffer.readInt32BE(offset) : buffer.readInt32LE(offset);
arrayOfInts.push(float);
}
return arrayOfInts;
}
/**
* Convert the base64 encoded int32 array to actually int32 values
* @param buffer base64 encoded string
* @param useBE use readInt32BE instead of readInt32LE
*/
export function convertBase64Integers(buffer: string, useBE: boolean = false) {
// Decode base64
const decodedBuffer = new Buffer(buffer, 'base64');
// Int32 => 4 bytes
// Get number of integer values
const intValuesCount = decodedBuffer.length / 4;
// New array with correct floats
const arrayOfInts: number[] = [];
// Get float32s from buffer
for (let i = 0; i < intValuesCount; i++) {
const offset = i * 4;
const float = useBE ? decodedBuffer.readInt32BE(offset) : decodedBuffer.readInt32LE(offset);
arrayOfInts.push(float);
}
// Return new array of correct float values
return arrayOfInts;
}
同一个数据集还包含变量 strokePath,看起来很相似。也是一个带有坐标的数组,称为extremePoints。
这是完整数据集的链接,编码为 json:https ://pastebin.com/sadZAvyS
数据集表示以下形状:
也许对几何形状有更多经验的人可以向我解释这个数据结构如何表示部分形状。
编辑:我刚刚注意到,这也可能是部分形状中的一个小元素的数据。
解决方案
还不是一个答案,而是一个开始:
查看 outlinePath 和 strokePath 的 hexdump -c,数据看起来是结构化的(未压缩),这留下了解码的希望:
0000000 % ³ å H 002 \0 \0 \0 \0 003 ¿ 037 Ô K ! |
0000010 T @ ¶ N t ¶ á k Z @ 213 T ø a ò ©
0000020 T @ h à 225 ß È 212 Z @ 020 ! 236 ² 026 Ö
0000030 T @ 7 M \r < û « Z @ 001 Â 030 025 d \0
0000040 U @ Ö ( . £ N Ï Z @
000004a
和
0000000 % ³ å H 005 \0 \0 \0 \0 003 003 003 003 V G j
0000010 Ì ¶ 7 R @ Æ p á 200 © l Y @ ¹ D z
0000020 a i » R @ æ ä r \t ï 206 Y @ 032 ¡ 204
0000030 q \ 9 S @ Ê 236 204 034 $ ± Y @ u e
0000040 214 w ¯ S @ n z z U 0 é Y @ § v y
0000050 º i « S @ - 4 217 Ì Ü ï Y @ B ó l
0000060 Ÿ # § S @ Ì í X Ê ö Y @ ª E Ñ
0000070 \b š ¢ S @ 033 œ : O \v þ Y @ 023 , O
0000080 212 . , S @ ª s ² \f 020 Æ Y @ Î · 1
0000090 G ¹ R @ § A 224 } 5 234 Y @ L K î
00000a0 Á t ) R @ p 8 Ã 0 š 202 Y @ l e Ý
00000b0 = s . R @ 210 & O Û + { Y @ @ 237 §
00000c0 º 4 3 R @ 035 L Š Ä Ô s Y @ V G j
00000d0 Ì ¶ 7 R @ Æ p á 200 © l Y @
00000dd
您会注意到一个常见的 4 字节标头,后跟一个小数字 002 或 005,4 个空字节,1 或 4 倍 003,然后是 8 或 26 个 8 字节序列,全部以字母结尾 (T|Z|U |R|S|Y) 和@。
推荐阅读
- c++ - 写出正确的逻辑表达式
- xamarin.forms - 用于 UWP 的 Xamarin 表单集合视图 ItemsUpdatingScrollMode
- hibernate - 用于创建用户的参数化查询在 Spring Data JPA 中抛出丢失的用户或角色名称异常
- machine-learning - 如何自动选择时间序列模型进行预测?
- java - 如何破解 DataSource 以使用静态数据?(转换列表
到数据源 ) - javascript - 从字符串数组分配给 json 对象字段不起作用
- javascript - 增加对 JavaScript 中评估/执行的理解
- laravel - Quasar QList 分页与 QPagination 组件和 laravel paginate() 方法
- excel - 如何根据单词列表在excel中搜索列表以过滤掉
- python-3.x - 如果将索引列视为类型的一部分,请键入提示和熊猫