Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-12 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 12 March 2023 at 00:54:53 UTC, zjh wrote: On Saturday, 11 March 2023 at 19:56:09 UTC, 0xEAB wrote: If you desire to use other encodings, how about using ubyte + ubyte[]? There is no example. To read binary data from a file and dump it into another, you do: ```d import std.file

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-11 Thread 0xEAB via Digitalmars-d-learn
On Friday, 10 March 2023 at 07:16:32 UTC, zjh wrote: `D language` is too unfriendly for Chinese users! You can't even write `gbk` files. D’s char + string types are Unicode. To quote the tour, “In D, *all* strings are Unicode strings”. If you desire to use other encodings, how about using

DUB test and strings that look like D code

2023-03-04 Thread 0xEAB via Digitalmars-d-learn
Is it just me, or does this happen for someone else, too? Init a fresh DUB project and create a file (e.g. `lib.d`) with the following content: ```d unittest { string x = "module oh.dear.dub.what.are.you.doing;"; } ``` Then run `dub test`: ```

Re: Making sense out of scope and function calls

2022-11-13 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:36:48 UTC, Dennis wrote: Can you please provide a full example? I'm missing the definitions of _headers, hstring, values ```d /++ “HTTP message string” – short-hand for `const(char)[]``. $(SIDEBAR Not sure about the name. Would have

Making sense out of scope and function calls

2022-11-13 Thread 0xEAB via Digitalmars-d-learn
```d struct Foo { /* … */ hstring[] getHeader(LowerCaseToken name) scope return { return _headers[name].values; } hstring[] getHeader(hstring name)() scope return { enum token = LowerCaseToken.makeConverted(name); return this.getHeader(token); // line

return scope vs. scope return

2022-11-05 Thread 0xEAB via Digitalmars-d-learn
Apparently there a difference between: - ```d Message withBody(Body body_) return scope { /* … */ } ``` - ```d Message withBody(Body body_) scope return { /* … */ } ``` ``` Deprecation: returning `this._body` escapes a reference to parameter `this` perhaps change the `return

ubyte + ubyte = int

2022-10-26 Thread 0xEAB via Digitalmars-d-learn
```d @safe: void main() { import std.stdio : writeln; writeln(ubyte(4).toHexDigit); } ubyte toHexDigit(ubyte decimal) pure nothrow @nogc { if (decimal < 10) return (decimal + ubyte('0')); if (decimal < 16) return (decimal - ubyte(10) + ubyte('A')); return

Re: Install DCD language server on Raspberrry PI4 (aarch64) requires rdmd , command not found.

2022-05-21 Thread 0xEAB via Digitalmars-d-learn
On Saturday, 21 May 2022 at 23:38:18 UTC, rikki cattermole wrote: […] I grabbed a copy of ldc2-1.24.0-linux-aarch64, it has rdmd. Something is messed up with that package if it does not include it (assuming it hasn't be split out into a tools package). iirc Debian & derivates do not package

Re: vibe.d / experience / feedback

2020-10-03 Thread 0xEAB via Digitalmars-d-learn
On Saturday, 3 October 2020 at 07:54:58 UTC, Martin wrote: On Friday, 2 October 2020 at 09:46:09 UTC, Denis Feklushkin wrote: Because standard implementation worse? What do you mean with "worse"? It's said to be pretty slow…

Are @safe unittests actually checked for safety?

2020-09-07 Thread 0xEAB via Digitalmars-d-learn
Are unittests that are marked @safe actually checked for safety? https://github.com/dlang/phobos/blob/v2.093.1/std/file.d#L4937 How comes this unittest is @safe when `dirEntries` appears to be @system? Example I: https://run.dlang.io/is/Vf0STw Error: @safe function onlineapp.listdir

Re: Why are extern(C/C++) definitions and references mangled differently in separately compiled modules?

2019-09-06 Thread 0xEAB via Digitalmars-d-learn
On Friday, 6 September 2019 at 15:09:22 UTC, Max Samukha wrote: Consider the following two modules: What compiler version are you using?

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread 0xEAB via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 06:30:03 UTC, BoQsc wrote: On Wednesday, 31 July 2019 at 05:56:46 UTC, BoQsc wrote: what causes the Internal Server Error. Internal Server Error might as well appear when D language syntax is not correct. Maybe you want to use some wrapper around rdmd that

Re: How to setup D language with Apache httpd cgi?

2019-07-31 Thread 0xEAB via Digitalmars-d-learn
On Wednesday, 31 July 2019 at 06:30:03 UTC, BoQsc wrote: This can be solved by using single quotes in the argument content places #!/usr/bin/env rdmd import std.stdio; void main() { writeln("Content-type: text/html"); writeln(""); writeln("CGI D Example"); } Does the job but is a

Re: Why does `static foreach` lead to something calling `~=` internally?

2019-07-07 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote: Why does this `static foreach` lead to hidden usage of operator Further notes by Dan (aka "Wild"): I added some small printfs to the compiler, http://ix.io/1NWM It seems like it lowers it into something weird

Why does `static foreach` lead to something calling `~=` internally?

2019-07-07 Thread 0xEAB via Digitalmars-d-learn
Why does this `static foreach` lead to hidden usage of operator `~=` calls in some cases? static foreach(i; 0 .. cnt) onlineapp.d(9): Error: cannot use operator ~= in @nogc delegate onlineapp.xv!(myUDA("/")).__funcliteral2.__lambda1 import std.traits; private @safe pure nothrow @nogc

Re: nice-curses releases / dub version git?

2019-01-12 Thread 0xEAB via Digitalmars-d-learn
On Saturday, 12 January 2019 at 12:10:25 UTC, Droggl wrote: 2. Is there a way to get a certain git-version (eg. commit or maybe even just "latest") for a package in dub? JSON: "nice-curses": "~master" SDL: dependency "nice-curses" version="~master" 3. How is everyone in general using curses

Re: Coedit almost works for me, except when I go to add peggged

2019-01-12 Thread 0xEAB via Digitalmars-d-learn
On Friday, 11 January 2019 at 18:40:08 UTC, Enjoys Math wrote: You will have to be more specific. I don't see dub.json anywhere within Coedit IDE. are you using DUB or not?

Re: Coedit almost works for me, except when I go to add peggged

2019-01-11 Thread 0xEAB via Digitalmars-d-learn
On Friday, 11 January 2019 at 18:27:37 UTC, Enjoys Math wrote: Dude, that doesn't work either. lol If you're using DUB, add the dependency manually to your project: "dependencies": {"pegged": "~>0.4.4"}

Re: All these errors running basic Pegged helloworld example.

2019-01-11 Thread 0xEAB via Digitalmars-d-learn
On Friday, 11 January 2019 at 17:35:40 UTC, Enjoys Math wrote: Thanks, I downloaded Coedit, but it's not working with pegged (using the library manager dub button) According to your post in [0], it didn't work because you had a typo in `pegged`. Maybe correct it and try again :) - Elias

Re: Reversing a string

2019-01-11 Thread 0xEAB via Digitalmars-d-learn
On Friday, 11 January 2019 at 13:51:04 UTC, JN wrote: On Friday, 11 January 2019 at 11:15:05 UTC, Mike James wrote: Check out the origin :-) https://forum.dlang.org/thread/hl8345$2b1q$1...@digitalmars.com?page=1 I guess something like iterReverse, reverseIter, backIterator would be too

Re: Weird combo of static function, templates, interfaces (that doesn't link)

2019-01-02 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 30 December 2018 at 18:55:10 UTC, Ali Çehreli wrote: On 12/30/2018 05:05 AM, 0xEAB wrote: >> interface FooAdapter >> { >> FooBundle!(Handle) createSome(Handle)(); >> } Function templates cannot be virtual functions. One reason is the compiler cannot know how large the virtual

Weird combo of static function, templates, interfaces (that doesn't link)

2018-12-30 Thread 0xEAB via Digitalmars-d-learn
void main() { StaticThingy.register(new SomeAdapter()); StaticThingy.createSome!Dummy(); } interface FooAdapter { FooBundle!(Handle) createSome(Handle)(); } private class SomeAdapter : FooAdapter { Bundle createSome() { auto w = new Dummy(); auto c = new

Re: Array!bool -> Chunks -> foreach: out of bounds

2018-08-17 Thread 0xEAB via Digitalmars-d-learn
On Wednesday, 15 August 2018 at 18:27:56 UTC, Steven Schveighoffer wrote: PR: https://github.com/dlang/phobos/pull/ -Steve Thank you for looking into this one. Regards, Elias

Re: Array!bool -> Chunks -> foreach: out of bounds

2018-08-15 Thread 0xEAB via Digitalmars-d-learn
On Wednesday, 15 August 2018 at 15:13:50 UTC, Kagamin wrote: It's a bug: Is it a known one?

Array!bool -> Chunks -> foreach: out of bounds

2018-08-15 Thread 0xEAB via Digitalmars-d-learn
core.exception.AssertError@/src/phobos/std/container/array.d(1667): Using out of bounds indexes on an Array Should this code[1] really try to access something out of bounds and assert? Also: shouldn't this assertion[2] be perhaps inside `version(D_NoBoundsChecks){} else { ... }` block?

Re: How to use LLD linker?

2018-07-07 Thread 0xEAB via Digitalmars-d-learn
On Friday, 6 July 2018 at 23:54:35 UTC, SrMordred wrote: Well, since its VS 2017 installer, eventually I hit all the components needed to install it properly. Now its working. Thanks 0xEAB for the tip about the Windows SDK too :) No problem :)

Re: How to use LLD linker?

2018-07-06 Thread 0xEAB via Digitalmars-d-learn
On Friday, 6 July 2018 at 03:48:04 UTC, SrMordred wrote: Well I just installed the VS 2017 to try the ldc and get (maybe) the same error. You didn't forget to install the Windows SDK with it, did you?

Re: How to use LLD linker?

2018-07-06 Thread 0xEAB via Digitalmars-d-learn
On Friday, 6 July 2018 at 17:32:09 UTC, SrMordred wrote: On Friday, 6 July 2018 at 10:55:47 UTC, Rainer Schuetze wrote: On 06/07/2018 05:48, SrMordred wrote: [...] The problem is that the Digital Mars linker is called but the Microsoft linker is run, because they share the same name

Copying an std.stdio.File into another one

2018-05-21 Thread 0xEAB via Digitalmars-d-learn
What's the correct way to copy a `File` into another one in D? If `LockingTextReader` wasn't undocumented, I'd have gone for that approach: import std.algorithm.mutation : copy; import std.stdio : File, LockingTextReader; void main() { auto a = File("a.txt", "r"); auto b =

Re: unittest-cov - results?

2017-07-25 Thread 0xEAB via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 19:13:21 UTC, Jolly James wrote: On Wednesday, 5 July 2017 at 19:01:06 UTC, Jonathan M Davis wrote: On Wednesday, July 05, 2017 18:50:32 Jolly James via Digitalmars-d-learn wrote: On Wednesday, 5 July 2017 at 18:46:38 UTC, Jolly James wrote: > [...] I have changed