[Issue 6255] New: Add support for different base conversions in std.conv

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 5 15:03:43 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6255

           Summary: Add support for different base conversions in std.conv
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-07-05 14:58:40 PDT ---
This doesn't work currently:
to!int("0xFF");

Python's int() function solves this by taking an optional base argument:
http://docs.python.org/library/functions.html#int

So it can be called like:
clr = int("0000FF", 16)

I've seen this used in some functions which convert web colors to an integer.

So std.conv could take an optional base argument or maybe try to parse the
string and figure out if it's hexadecimal (since this is probably the most
commonly used base after base-10).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list