Bug 12348 – toImpl(Target,Source)(Source source, radix) add range support
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-11T09:04:00Z
Last change time
2014-03-11T14:23:12Z
Assigned to
nobody
Creator
kozzi11
Comments
Comment #0 by kozzi11 — 2014-03-11T09:04:12Z
Few days ago I need convert ascii7 binary string into chars.
For example something like this:
string str = "10101011010101"; // contains "UU"
So my first attempt has been something like this:
foreach(chunk; str.chunks(7)) {
write(to!char(chunk,2));
}
It doesn't work.
But this works ok:
foreach(chunk; str.chunks(7)) {
write(to!char(to!ubyte(to!string(chunk), 2))); // but seems ugly
//write(to!char(parse!ubyte(chunk, 2))); //this works too but still not perfect
}
It would be great if the code from my first attempt works
Comment #1 by bearophile_hugs — 2014-03-11T09:09:45Z
This is a basic need. So perhaps it's already in Bugzilla, please search for it.
Comment #2 by safety0ff.bugz — 2014-03-11T13:53:17Z
(In reply to comment #1)
> This is a basic need. So perhaps it's already in Bugzilla, please search for
> it.
Issue #10175?
Comment #3 by bearophile_hugs — 2014-03-11T14:23:12Z
(In reply to comment #2)
> (In reply to comment #1)
> > This is a basic need. So perhaps it's already in Bugzilla, please search for
> > it.
>
> Issue #10175?
Yes, right.
*** This issue has been marked as a duplicate of issue 10175 ***