On Friday, December 14, 2012 00:27:39 Dmitry Olshansky wrote: > 12/13/2012 7:22 AM, Jonathan M Davis пишет: > > On Wednesday, December 12, 2012 17:34:53 Ali Çehreli wrote: > >> (There must be an easier way of doing that. :)) > > > > If you have a string that's really ASCII and you're _sure_ that it's only > > ASCII, then I'd suggest simply casting it to immutable(ubyte)[] and > > operating on that with all range based functions. That way, no decoding > > occurs, and you don't have to dup the string. If you want, you could also > > easily create a funtion called something like assumeASCII that did that > > cast in order to make it more idiomatic (similar to > > std.exception.assumeUnique). > > Yup. Plus there is a not commonly known 'representation' function that > does just that for (w|d|)string: > > auto repro = lowercase.representation; > //typeof(repro) should be immutable(ubyte)[]
Wow. Good to know about that one. I feel kind of stupid for not realizing that it was there given how much I've worked in std.string. And here I was doing that cast manually in some of my code recently and having to put comments to indicate why I was doing it. std.string.representation is much better. - Jonathan M Davis