Created
July 29, 2012 13:36
-
-
Save JakobOvrum/3198842 to your computer and use it in GitHub Desktop.
byte array to hex string
This file contains hidden or 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
import std.stdio; | |
import std.format; | |
import std.array; | |
void main() | |
{ | |
ubyte[] data = [0xAA, 0xFF]; | |
auto app = appender!string(); | |
foreach(b; data) | |
formattedWrite(app, "%02X", b); | |
writeln(app.data); // AAFF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment