Re: Ascii string literal.

2016-05-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 7 May 2016 at 01:37:30 UTC, Jonathan M Davis wrote: In general, it's better to use representation than to cast, because representation gets the constness right, whereas if you cast, there's always the risk that you won't. Yeah, if it is a general thing, but here it is a simple fu

Re: Ascii string literal.

2016-05-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 06 May 2016 21:57:22 + "Adam D. Ruppe via Digitalmars-d-learn" wrote: > On Friday, 6 May 2016 at 21:39:35 UTC, Anonymouse wrote: > > Is this different from what std.string.representation does? > > No, it does the same thing, but with your own function the > intention may be clearer (o

Re: Ascii string literal.

2016-05-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 May 2016 at 21:39:35 UTC, Anonymouse wrote: Is this different from what std.string.representation does? No, it does the same thing, but with your own function the intention may be clearer (or you could do a template to avoid any function or custom types too)

Re: Ascii string literal.

2016-05-06 Thread Anonymouse via Digitalmars-d-learn
On Friday, 6 May 2016 at 20:29:35 UTC, Adam D. Ruppe wrote: On Friday, 6 May 2016 at 20:01:27 UTC, Alexandru Ermicioi wrote: Is it possible somehow to convert implicitly a string literal Not implicitly (well, unless you just use string, ascii is a strict subset of utf-8 anyway), but you could

Re: Ascii string literal.

2016-05-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 May 2016 at 20:01:27 UTC, Alexandru Ermicioi wrote: Is it possible somehow to convert implicitly a string literal Not implicitly (well, unless you just use string, ascii is a strict subset of utf-8 anyway), but you could do it explicitly easily. immutable(ubyte)[] ascii(string

Ascii string literal.

2016-05-06 Thread Alexandru Ermicioi via Digitalmars-d-learn
, is there an us-ascii string literal that consists of ubytes and not chars? It's just in some of my code should work only with ascii strings, and it will be cumbersome to convert to ubyte array a string literal each time a function accepting an ubyte array is called. Thank you.