Integer to hexadecimal string

Dave Akers dragon at dazoe.net
Tue Jul 8 16:33:22 PDT 2008


jicman wrote:
> novice2 Wrote:
> 
>> jicman Wrote:
>>
>>> other files.  This file which this COM object uses as input I create using D.  
>>> This file is created by my doing a std.file.listdir(fd,"*") and then using 
>> imho, you should use std.windows.charset.toMBSz() while you pass string from D to Windows API,
>> and std.windows.charset.fromMBSz() while you pass string back from Windows API to D
> 
> Is this part of Phobos 1.0?  I only see in in Phobos 2.0. Is there a similar call within Phobos 1.0?

why not use format??
char[] hex = format("%.8x", 12345);

that produces hex..

import std.string;
char[] toHex(T)(T arg){
	return format("%."~std.string.toString(T.sizeof * 2)~"x", arg);
}


i haven't tested that code. but i think it'd work for ulong long uint 
int ubyte and byte.

-dave


More information about the Digitalmars-d-learn mailing list