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

2023-03-09 Thread John Xu via Digitalmars-d-learn
I found this: https://github.com/meatatt/exCode/blob/master/source/excode/package.d There is mention of unicode/GBK conversion, maybe it could be helpful Thanks for quick answers. Now I found I can read both UTF8 and UTF-16LE chinese file: string txt =

How to expand wildchar under dos ?

2023-03-09 Thread John Xu via Digitalmars-d-learn
Under dos, how to get wildchar matched file names? PS E:> dmd a.d PS E:> .\a.exe a.* args=["a.exe", "a.*"] d-glob doesn't function well under windows dos either.

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

2023-03-06 Thread John Xu via Digitalmars-d-learn
I'm new to dlang. I didn't find much tutorials on internet about how to read/write Chinese easily. std.encoding doesn't seem to support GBK or GB18030: "Encodings currently supported are UTF-8, UTF-16, UTF-32, ASCII, ISO-8859-1 (also known as LATIN-1), ISO-8859-2 (LATIN-2), WINDOWS-1250,

Any working REPL program on windows? DREPL doesn't compile

2023-03-23 Thread John Xu via Digitalmars-d-learn
Anybody know any working REPL program? I failed to find a working one. https://github.com/dlang-community/drepl can't compile on my Windows 10, dub reports: src\drepl\engines\dmd.d(258,16): Error: undefined identifier `dlsym`

Re: How get struct value by member name string ?

2023-05-29 Thread John Xu via Digitalmars-d-learn
On Monday, 29 May 2023 at 11:21:11 UTC, Adam D Ruppe wrote: On Monday, 29 May 2023 at 09:35:11 UTC, John Xu wrote: Error: variable `column` cannot be read at compile time you should generally getMember on a variable T t; __traits(getMember, t, "name") like that, that's as if you wrote

How get struct value by member name string ?

2023-05-29 Thread John Xu via Digitalmars-d-learn
I saw ddbc (https://github.com/buggins/ddbc/blob/master/source/ddbc/pods.d) uses static if (__traits(compiles, (typeof(__traits(getMember, T, m) { __traits(getMember, T, m) } But for my experience, above code sometimes/somewhere works, sometimes/somewhere just doesn't:

Re: How get struct value by member name string ?

2023-05-30 Thread John Xu via Digitalmars-d-learn
On Tuesday, 30 May 2023 at 01:33:54 UTC, H. S. Teoh wrote: On Tue, May 30, 2023 at 01:24:46AM +, John Xu via Digitalmars-d-learn wrote: On Monday, 29 May 2023 at 11:21:11 UTC, Adam D Ruppe wrote: > On Monday, 29 May 2023 at 09:35:11 UTC, John Xu wrote: > > Error: variabl

Re: How get struct value by member name string ?

2023-05-30 Thread John Xu via Digitalmars-d-learn
On Tuesday, 30 May 2023 at 15:43:12 UTC, Steven Schveighoffer wrote: On 5/30/23 4:46 AM, John Xu wrote: How to put above enum as a function parameter? Following code wouldn't work:     string getTMember(T t, enum string memberName) {     return __traits(getMember, t, memberName);     }

Re: How get struct value by member name string ?

2023-06-01 Thread John Xu via Digitalmars-d-learn
A correction: string getTMember(T t, string columnName) { foreach(member; __traits(allMembers, T)){ if (member == columnName) { return __traits(getMember, t, member).to!string; } } return ""; }

Re: How get struct value by member name string ?

2023-06-01 Thread John Xu via Digitalmars-d-learn
On Thursday, 1 June 2023 at 15:38:08 UTC, Steven Schveighoffer wrote: On 5/31/23 12:08 AM, John Xu wrote: When render vibe.d diet template,     string[] allMembers = __traits(allMembers, t); enum allMembers = __traits(allMembers, t);     res.render!("index.dt", t, allMembers) if I

How hide console in dub.sdl under windows 11?

2023-05-25 Thread John Xu via Digitalmars-d-learn
For dmd, I can use a no_console.def file, which has: EXETYPE NT SUBSYSTEM WINDOWS Then `dmd my.d no_console.def` to hide console. But how do I realize it with dub.sdl ? Adding no_console.def to "sourceFiles", doesn't help.

What's dxml DOMEntity(R) type ?

2023-06-05 Thread John Xu via Digitalmars-d-learn
The parseDOM returns a DOMEntity(R) type, how do I write a xmlRoot as global variable? I need its detailed type (auto / Variant doesn't work). import dxml.dom; ?? xmlRoot; int main() { string xml = readText("a.xml"); auto dom = parseDOM(xml);

Re: What's dxml DOMEntity(R) type ?

2023-06-05 Thread John Xu via Digitalmars-d-learn
On Monday, 5 June 2023 at 10:43:27 UTC, Ferhat Kurtulmuş wrote: On Monday, 5 June 2023 at 10:01:01 UTC, John Xu wrote: The parseDOM returns a DOMEntity(R) type, how do I write a xmlRoot as global variable? I need its detailed type (auto / Variant doesn't work). import dxml.dom;

Best way to convert between GBK/GB18030 to utf8 ?

2023-05-22 Thread John Xu via Digitalmars-d-learn
What is the best way to convert a GBK/GB18030 file contents, i.e. read via: std.stdio.read(gbkFile).to!string , to utf8 encoding ?

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-22 Thread John Xu via Digitalmars-d-learn
On Friday, 19 May 2023 at 21:19:07 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/05/2023 9:39 PM, John Xu wrote: On Thursday, 18 May 2023 at 15:39:05 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/05/2023 2:19 AM, John Xu wrote: On Monday, 15 May 2023 at 03:54:03 UTC, Richard

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-14 Thread John Xu via Digitalmars-d-learn
On Friday, 12 May 2023 at 02:09:17 UTC, ryuukk_ wrote: create a ``ressource.rc`` file and paste: ``` IDI_ICON1 ICON DISCARDABLE "myicon.ico" ``` then put your ``mycon.ico`` file next to it ``` my_project\ app.d ressource.rc myicon.ico ``` ``` dmd app.d ressource.rc Thanks for

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-14 Thread John Xu via Digitalmars-d-learn
On Monday, 15 May 2023 at 02:45:17 UTC, John Xu wrote: Found a related link: https://forum.dlang.org/thread/wogdypudrmrgwjysf...@forum.dlang.org Where Adam D Ruppe informed rcc.exe from http://ftp.digitalmars.com/bup.zip ... Any help? My isp.ico was converted from a png with gimp, used in C#

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-14 Thread John Xu via Digitalmars-d-learn
Found a related link: https://forum.dlang.org/thread/wogdypudrmrgwjysf...@forum.dlang.org Where Adam D Ruppe informed rcc.exe from http://ftp.digitalmars.com/bup.zip But, I got problem: rcc -r .\resource.rc IDI_ICON1 ICON DISCARDABLE "isp.ico" ^ .\resource.rc(1) : Error:

Re: Where can I find D jobs?

2023-05-16 Thread John Xu via Digitalmars-d-learn
On Saturday, 29 April 2023 at 00:31:21 UTC, Neto wrote: On Saturday, 29 April 2023 at 00:29:28 UTC, Neto wrote: I'm thinking in moving from freelancer to some company, but I'd like to use D. Are there any companies hiring where D is used? note: hire without a degree. and remote. I received

Re: Any working REPL program on windows? DREPL doesn't compile

2023-05-11 Thread John Xu via Digitalmars-d-learn
On Thursday, 23 March 2023 at 13:27:00 UTC, jmh530 wrote: I've composed a simple gui, partially solved my problem: to compile/test simple codes quickly: https://github.com/xucs007/dln

Can dmd compile a favicon.ico to exe file ?

2023-05-11 Thread John Xu via Digitalmars-d-learn
I saw c# program's exe, often have an favicon.ico image bound together, which can be dragged to desktop. Can dmd compile an icon image to an exe also?

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-18 Thread John Xu via Digitalmars-d-learn
On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew Cattermole wrote: That is only for OMF target. You need rc that comes with Visual Studio C++ build tools. Alternatively windres from mingw may work (I haven't tested). How can I add this step to dub.sdl ?

Re: Can dmd compile a favicon.ico to exe file ?

2023-05-19 Thread John Xu via Digitalmars-d-learn
On Thursday, 18 May 2023 at 15:39:05 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/05/2023 2:19 AM, John Xu wrote: On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew Cattermole wrote: That is only for OMF target. You need rc that comes with Visual Studio C++ build tools.