Handling arbitrary char ranges
Alex Parrill via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Apr 20 11:20:39 PDT 2016
On Wednesday, 20 April 2016 at 17:09:29 UTC, Matt Kline wrote:
> I'm doing some work with a REST API, and I wrote a simple
> utility function that sets an HTTP's onSend callback to send a
> string:
>
> [...]
IO functions usually work with octets, not characters, so an
extra encoding step is needed. For encoding character arrays to
UTF-#, there's std.string.representation, and std.encoding might
have something for arbitrary ranges.
Avoid slicing ranges; not all ranges support it. If you
absolutely need it (you don't here) then add hasSlicing to the
constraint.
isSomeChar can tell you if a type (like the ranges element type)
is a character.
More information about the Digitalmars-d-learn
mailing list