Re: Write UTF-8 bytes directly to stack buffer

2022-03-13 Thread Brian Callahan via Digitalmars-d-learn
On Sunday, 13 March 2022 at 07:55:01 UTC, Chris Piker wrote: Hey thanks! That does work with recent versions of dmd+phobos, but doesn't work in gdc-10. For some reason it produces this error: ```d error: static assert "Cannot put a const(char)[] into a char[]." ``` Is there a work arou

Re: Write UTF-8 bytes directly to stack buffer

2022-03-13 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 10 March 2022 at 17:59:33 UTC, H. S. Teoh wrote: Probably what you're looking for is std.format.formattedWrite. For example: ```d import std; void main() { ubyte[65536] buf; char[] usable_buf = cast(char[]) buf[]; usable_buf.formattedWrite!"Blah %d blah %s"(123, "Э

Re: Write UTF-8 bytes directly to stack buffer

2022-03-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 10, 2022 at 05:39:34PM +, Chris Piker via Digitalmars-d-learn wrote: > Hi D > > There are quite a few string, array and range functions in phobos so > I'm getting confused as to the right way to encode string data as > UTF-8 directly into a stack buffer while keeping track of the

Write UTF-8 bytes directly to stack buffer

2022-03-10 Thread Chris Piker via Digitalmars-d-learn
Hi D There are quite a few string, array and range functions in phobos so I'm getting confused as to the right way to encode string data as UTF-8 directly into a stack buffer while keeping track of the write point. I have some output packets I'm building up in a tight loop. For speed I'm u