Created
December 3, 2023 09:17
-
-
Save aneury1/a2fa4257dabeb812ac315263dd2f98b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void testM() | |
{ | |
// 37 78 81 85 27 68 07 4d 21 11 20 11 71 05 57 65 00 00 | |
// 37 78 81 85 27 68 07 4d 21 11 20 11 71 5 57 65 00 00 | |
// track2 4-bit BCD encode | |
std::string track2 = "377881852768074=211120117105576500001"; | |
std::string encoded = ""; | |
uint8_t acc = 0; | |
bool full = false; | |
for (uint8_t c : track2) | |
{ | |
if (!full) | |
{ | |
acc = c - 0x30; | |
acc <<= 4; | |
full = !full; | |
} | |
else | |
{ | |
acc |= c - 0x30; | |
std::cout<< | |
std::hex<< unsigned(acc) << " "; | |
encoded.append(1, acc); | |
acc = 0; | |
full = !full; | |
} | |
} | |
} | |
///https://ryandeangraham.medium.com/track2-character-encoding-61d6150ecb95 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment