Re: Wired question related with Chinese characters

2020-03-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 23 March 2020 at 01:18:15 UTC, walker wrote: Which function should I use when I read Chinese characters in the terminal? Terminal.getline *might* work in my lib, but if there's combining codepoints I'm not sure. You can try it though and let me know if you are already using the

Re: Wired question related with Chinese characters

2020-03-22 Thread walker via Digitalmars-d-learn
On Sunday, 22 March 2020 at 16:12:34 UTC, Adam D. Ruppe wrote: Thank you! Your arsd.terminal is the first 3rd party module I used, which I use to output colored text on the terminal preview on windows10. I have tried your code above with both string and dstring, It works! Really good!

Re: Wired question related with Chinese characters

2020-03-22 Thread walker via Digitalmars-d-learn
On Sunday, 22 March 2020 at 15:53:29 UTC, Steven Schveighoffer wrote: On windows, the default codepage for the terminal is NOT UTF8. Which means it may not know how to properly deal with your output. Most likely nim is making the terminal use the UTF8 codepage. See more info here:

Re: Best way to learn 2d games with D?

2020-03-22 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Sunday, 15 March 2020 at 17:58:58 UTC, Steven Schveighoffer wrote: I want to try and learn how to write 2d games. I'd prefer to do it with D. I've found a ton of tutorials on learning 2d gaming with other languages. Is there a place to look that uses D for learning? Should I just start

Re: linking obj files compiled with LDC2 1.20.0 on Win64

2020-03-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/22/20 2:43 PM, realhet wrote: Hello, I'm try to use the latest LDC2 version: 1.20.0 Previously I used 1.6.0 After fixing all the compiler errors and warnings, I managed to compile all the d source files to obj files, and I got 4 linking errors. I think all of them caused by the first 2:

Re: return val if

2020-03-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/22/20 3:04 PM, Dennis wrote: On Sunday, 22 March 2020 at 18:48:32 UTC, Abby wrote: Is there a way to create a template that would do the same is glib g_return_val_if_fail() (https://developer.gnome.org/glib/stable/glib-Warnings-and-Assertions.html#g-return-val-if-fail) I'm not

Re: return val if

2020-03-22 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 22 March 2020 at 19:04:40 UTC, Mike Parker wrote: ``` T returnValIfFail(T)(bool expr, T val) { if(expr) return val; else assert(0); } ``` Heh, of course, as Dennis pointed out, that's essentialy assert(expr). ``` assert(expr); x = val; ```

Re: return val if

2020-03-22 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 22 March 2020 at 18:48:32 UTC, Abby wrote: Is there a way to create a template that would do the same is glib g_return_val_if_fail() (https://developer.gnome.org/glib/stable/glib-Warnings-and-Assertions.html#g-return-val-if-fail) I was hoping something like this would work

Re: return val if

2020-03-22 Thread Dennis via Digitalmars-d-learn
On Sunday, 22 March 2020 at 18:48:32 UTC, Abby wrote: Is there a way to create a template that would do the same is glib g_return_val_if_fail() (https://developer.gnome.org/glib/stable/glib-Warnings-and-Assertions.html#g-return-val-if-fail) I'm not famililar with glib, but the description:

return val if

2020-03-22 Thread Abby via Digitalmars-d-learn
Is there a way to create a template that would do the same is glib g_return_val_if_fail() (https://developer.gnome.org/glib/stable/glib-Warnings-and-Assertions.html#g-return-val-if-fail) I was hoping something like this would work template returnValIfFail(alias expr, alias val) {

linking obj files compiled with LDC2 1.20.0 on Win64

2020-03-22 Thread realhet via Digitalmars-d-learn
Hello, I'm try to use the latest LDC2 version: 1.20.0 Previously I used 1.6.0 After fixing all the compiler errors and warnings, I managed to compile all the d source files to obj files, and I got 4 linking errors. I think all of them caused by the first 2: 1: msvcrt.lib(initializers.obj) :

Re: Wired question related with Chinese characters

2020-03-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 22 March 2020 at 15:19:13 UTC, walker wrote: writeln(var1); writeln calls the wrong function for the Windows console. You can kinda hack it by changing the code page like Steven said (which has other bugs though, but works for many cases), or you can call the correct function -

Re: Wired question related with Chinese characters

2020-03-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/22/20 11:19 AM, walker wrote: I am new to dlang, I like it :) I am on windows10 and use the terminal preview to test and run programs. In order to print Chinese characters correctly, I always use void main() { string var1 = "你好"; # to!string(in_other_conditions) writeln(var1); } I tried

Wired question related with Chinese characters

2020-03-22 Thread walker via Digitalmars-d-learn
I am new to dlang, I like it :) I am on windows10 and use the terminal preview to test and run programs. In order to print Chinese characters correctly, I always use void main() { string var1 = "你好"; # to!string(in_other_conditions) writeln(var1); } I tried dstring but not working. Need Help

Re: can a unittest read main()'s args?

2020-03-22 Thread mark via Digitalmars-d-learn
On Sunday, 22 March 2020 at 07:59:01 UTC, rikki cattermole wrote: On 22/03/2020 8:57 PM, mark wrote: I have a module with a unittest { ... } block. However, when I run dub test sometimes I want to output some extra data when the test runs. At the moment I control this by using an environment

can a unittest read main()'s args?

2020-03-22 Thread mark via Digitalmars-d-learn
I have a module with a unittest { ... } block. However, when I run dub test sometimes I want to output some extra data when the test runs. At the moment I control this by using an environment variable, but I wondered if it was possible to pass a command line argument 'dub test myarg' and if so

Re: can a unittest read main()'s args?

2020-03-22 Thread rikki cattermole via Digitalmars-d-learn
On 22/03/2020 8:57 PM, mark wrote: I have a module with a unittest { ... } block. However, when I run dub test sometimes I want to output some extra data when the test runs. At the moment I control this by using an environment variable, but I wondered if it was possible to pass a command line