Re: Want to read a whole file as utf-8

2015-02-04 Thread Foo via Digitalmars-d-learn
Since I'm now almost finished, I'm glad to show you my work: https://github.com/Dgame/m3 You're free to use it or to contribute to it.

Want to read a whole file as utf-8

2015-02-03 Thread Foo via Digitalmars-d-learn
How can I do that without any GC allocation? Nothing in std.file seems to be marked with @nogc I'm asking since it seems very complicated to do that with C++, maybe D is a better choice, then we would probably move our whole project from C++ to D.

Re: Want to read a whole file as utf-8

2015-02-03 Thread FG via Digitalmars-d-learn
On 2015-02-03 at 19:53, Foo wrote: How can I do that without any GC allocation? Nothing in std.file seems to be marked with @nogc I'm asking since it seems very complicated to do that with C++, maybe D is a better choice, then we would probably move our whole project from C++ to D. Looks

Re: Want to read a whole file as utf-8

2015-02-03 Thread Tobias Pankrath via Digitalmars-d-learn
On Tuesday, 3 February 2015 at 19:44:49 UTC, FG wrote: On 2015-02-03 at 19:53, Foo wrote: How can I do that without any GC allocation? Nothing in std.file seems to be marked with @nogc I'm asking since it seems very complicated to do that with C++, maybe D is a better choice, then we would

Re: Want to read a whole file as utf-8

2015-02-03 Thread FG via Digitalmars-d-learn
On 2015-02-03 at 20:50, Tobias Pankrath wrote: Use std.utf.validate instead of decode. It will only allocate one exception if necessary. Looks to me like it uses decode internally... But Foo, do you have to use @nogc? It still looks like it's work in progress, and lack of it doesn't mean

Re: Want to read a whole file as utf-8

2015-02-03 Thread Foo via Digitalmars-d-learn
On Tuesday, 3 February 2015 at 19:56:37 UTC, FG wrote: On 2015-02-03 at 20:50, Tobias Pankrath wrote: Use std.utf.validate instead of decode. It will only allocate one exception if necessary. Looks to me like it uses decode internally... But Foo, do you have to use @nogc? It still looks like

Re: Want to read a whole file as utf-8

2015-02-03 Thread Foo via Digitalmars-d-learn
On Tuesday, 3 February 2015 at 19:44:49 UTC, FG wrote: On 2015-02-03 at 19:53, Foo wrote: How can I do that without any GC allocation? Nothing in std.file seems to be marked with @nogc I'm asking since it seems very complicated to do that with C++, maybe D is a better choice, then we would

Re: Want to read a whole file as utf-8

2015-02-03 Thread Nordlöw
On Tuesday, 3 February 2015 at 18:53:28 UTC, Foo wrote: How can I do that without any GC allocation? Nothing in std.file seems to be marked with @nogc I'm asking since it seems very complicated to do that with C++, maybe D is a better choice, then we would probably move our whole project

Re: Want to read a whole file as utf-8

2015-02-03 Thread FG via Digitalmars-d-learn
On 2015-02-04 at 00:07, Foo wrote: How would I use decoding for that? Isn't there a way to read the file as utf8 or event better, as unicode? Well, apparently the utf-8-aware foreach loop still works just fine. This program shows the file size and the number of unicode glyps, or whatever

Re: Want to read a whole file as utf-8

2015-02-03 Thread Tobias Pankrath via Digitalmars-d-learn
On Tuesday, 3 February 2015 at 23:07:03 UTC, Foo wrote: On Tuesday, 3 February 2015 at 19:44:49 UTC, FG wrote: On 2015-02-03 at 19:53, Foo wrote: How can I do that without any GC allocation? Nothing in std.file seems to be marked with @nogc I'm asking since it seems very complicated to do

Re: Want to read a whole file as utf-8

2015-02-03 Thread Namespace via Digitalmars-d-learn
On Tuesday, 3 February 2015 at 23:55:19 UTC, FG wrote: On 2015-02-04 at 00:07, Foo wrote: How would I use decoding for that? Isn't there a way to read the file as utf8 or event better, as unicode? Well, apparently the utf-8-aware foreach loop still works just fine. This program shows the

Re: Want to read a whole file as utf-8

2015-02-03 Thread FG via Digitalmars-d-learn
On 2015-02-04 at 01:56, Namespace wrote: FILE* f = fopen(filename.ptr, rb); fseek(f, 0, SEEK_END); immutable size_t fsize = ftell(f); fseek(f, 0, SEEK_SET); That's quite a smart way to get the size of the file. I started with std.file.getSize (which obviously isn't