NFC: Fix NDEF parser for MIFARE Classic (#4153)

* Add div() to API

* Revert "Add div() to API"

This reverts commit e03b5c4244.

* Use / and %

* NFC: More MFC NDEF fixes

* Simplify duplicated code in MFC data generator

* NFC: Print NDEF hex data with pretty format

* NFC: Consider NDEF strings with last \0 byte as text

* Pretty Format: Add padding to last line to keep table width

---------

Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
WillyJL
2025-03-31 20:34:54 +00:00
committed by GitHub
parent f6916fe616
commit 0eb3fc33dd
3 changed files with 49 additions and 56 deletions

View File

@@ -36,11 +36,17 @@ void pretty_format_bytes_hex_canonical(
}
const size_t begin_idx = i;
const size_t end_idx = MIN(i + num_places, data_size);
const size_t wrap_idx = i + num_places;
const size_t end_idx = MIN(wrap_idx, data_size);
for(size_t j = begin_idx; j < end_idx; j++) {
furi_string_cat_printf(result, "%02X ", data[j]);
}
if(end_idx < wrap_idx) {
for(size_t j = end_idx; j < wrap_idx; j++) {
furi_string_cat_printf(result, " ");
}
}
furi_string_push_back(result, '|');