Thread overview
[Issue 6255] New: Add support for different base conversions in std.conv
Jul 05, 2011
Andrej Mitrovic
Jul 05, 2011
Andrej Mitrovic
Jul 06, 2011
yebblies
Dec 14, 2011
yebblies
Dec 15, 2011
Kenji Hara
Jan 26, 2012
Jonathan M Davis
July 05, 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@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@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: -------
July 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6255



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-07-05 14:59:31 PDT ---
I should have mentioned in the title that I'm looking for *string* to int conversions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6255


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com


--- Comment #2 from yebblies <yebblies@gmail.com> 2011-07-06 12:01:42 EST ---
Looking at the docs, it seems there's parse!int(string, radix) and
to!string(int, radix).  It's probably worth adding to!int(string, radix) as
well (unless it's already there and not showing up in the docs)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6255



--- Comment #3 from yebblies <yebblies@gmail.com> 2011-12-14 13:25:18 EST ---
*** Issue 6992 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6255


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
           Platform|Other                       |All
         OS/Version|Windows                     |All


--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2011-12-14 22:44:52 PST ---
https://github.com/D-Programming-Language/phobos/pull/372

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6255



--- Comment #5 from github-bugzilla@puremagic.com 2012-01-25 23:55:44 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/42083000a43b569e1d368261678ebd140586ee73 Merge pull request #372 from 9rnsr/fix6255

Issue 6255 - Add support for different base conversions in std.conv

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6255


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jmdavisProg@gmx.com
         Resolution|                            |FIXED


--- Comment #6 from github-bugzilla@puremagic.com 2012-01-26 00:04:20 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/bd9596f9625a6d9a196388b7c18813ccaf3da470 Added Issue# 6255 to the changelog.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6255



--- Comment #6 from github-bugzilla@puremagic.com 2012-01-26 00:04:20 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/bd9596f9625a6d9a196388b7c18813ccaf3da470 Added Issue# 6255 to the changelog.

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