Re: how to localize console and GUI apps in Windows

2017-12-29 Thread zabruk70 via Digitalmars-d-learn

On Friday, 29 December 2017 at 10:35:53 UTC, Andrei wrote:

Though it is not suitable for GUI type of a Windows application.


AFAIK, Windows GUI have no ANSI/OEM problem.
You can use Unicode.

For Windows ANSI/OEM problem you can use also
https://dlang.org/phobos/std_windows_charset.html



Re: how to localize console and GUI apps in Windows

2017-12-28 Thread zabruk70 via Digitalmars-d-learn

you can just set console CP to UTF-8:

https://github.com/CyberShadow/ae/blob/master/sys/console.d



Re: Building (and including libraries) without dub

2017-08-27 Thread zabruk70 via Digitalmars-d-learn

On Saturday, 26 August 2017 at 09:03:03 UTC, Hasen Judy wrote:
What if I want to include a 3rd party library? Surely before 
dub existed, people were incorporating other libraries in their 
projects.


sometimes pragma("lib", ...) very usefull (if i understand you 
correctly)


https://dlang.org/spec/pragma.html#lib


Re: Long File path Exception:The system cannot find the path specified

2017-08-25 Thread zabruk70 via Digitalmars-d-learn

On Thursday, 24 August 2017 at 18:02:24 UTC, vino wrote:

  Thanks for your support, was able to resolve this issue.


Hello.
IMHO, it will be better, if you will share your solution for 
other peoples :)


Re: Cannot find std.datetime when linking after upgrade to 2.075.0

2017-07-21 Thread zabruk70 via Digitalmars-d-learn

https://dlang.org/changelog/2.075.0.html#split-std-datetime


Re: What is Base64 part in Base64.encode

2017-05-14 Thread zabruk70 via Digitalmars-d-learn

On Sunday, 14 May 2017 at 21:22:20 UTC, Moritz Maxeiner wrote:

The full line is `alias Base64 = Base64Impl!('+', '/');`


Yes. When we use it like this:

  const(char)[] encoded = Base64.encode(data);

then template instantiated and produce ... what?


I don't understand what you're trying to express here.


What kind of symbols (class name, structure name, type)
can be used with dot in D language?

What produced by template instantiation `Base64Impl!('+', '/')`
then i use alias `Base64`?

You can create a base32 encoder however you like, D has lots of 
different ways you could approach this; you can even do it in a


But i want mimic std.base64 syntax.
I want to write something like

  string encoded = Base32.encode(data);

And i don't want to use template.


What is Base64 part in Base64.encode

2017-05-14 Thread zabruk70 via Digitalmars-d-learn

I look to std.base64 module source.
And dont unerstand what is the "Base64" part in 
"Base64.encode(data)" example.

I see std.base64 module use template Base64Impl.
I see alias Base64 = Base64Impl!...
But down understand.
Base64 not module, not structure, not class?
Template Base64Impl shoud produce function?

I want create base32 encoder/decoder for example.
But i dont need template.
So how i can write Base32.encode()?
By creating class Base32 with encode() member.
By creating structute Base32 with encode() member.
Any other options?

Thanx.


Re: union.sizeof

2017-03-26 Thread zabruk70 via Digitalmars-d-learn

On Sunday, 26 March 2017 at 07:18:14 UTC, ketmar wrote:
i.e. what compiler does (roughly) is inserting anonymous fields 
of the appropriate size *into* the container. for "inner" 
aligning compiler inserts anonymous fields *between* other 
fields. for "outer" aligning compiler just appends anonymous 
field at the *end* of a data type, so data type size will met 
align requirements.


Big thank!!


Re: union.sizeof

2017-03-26 Thread zabruk70 via Digitalmars-d-learn

On Sunday, 26 March 2017 at 06:45:13 UTC, ketmar wrote:

yes. you have a typo in second `writefln`: S1 instead of S2. ;-)


thank you.
another question, related to my first post:

why size of S2.b1 and S2.b2 still 3, not 4?

am i right: then align applied to members, compiler not change 
size of members, just make padding, so CONTAINER size changes?


if so (because size of S2.b1 and S2.b2 still is 3 in my code),
then adding align(1) outside of union must not change zise of 
union, but size of some comainer more upper level.


Re: union.sizeof

2017-03-26 Thread zabruk70 via Digitalmars-d-learn

On Sunday, 26 March 2017 at 06:38:59 UTC, zabruk70 wrote:

oh sorry sorry - mistyping

ok. DMD use padding, so for real container.sizeof
i should use lastMemeber.offsetof+lastMemeber.sizeof


Re: union.sizeof

2017-03-26 Thread zabruk70 via Digitalmars-d-learn

On Sunday, 26 March 2017 at 05:09:15 UTC, ketmar wrote:

most of the time either location or padding will work the same.


hmm.. you ruined my expirence..

i made another experiment.
whould you please explain me S2 size 6?
thank you for you time.

https://dpaste.dzfl.pl/9a31b6e370a0

struct S1 //sizeof=6
{
  align(1):
  byte[3] b1; //offsetof=0, sizeof=3
  byte[3] b2; //offsetof=3, sizeof=3
}

struct S2 //sizeof must be 7, but DMD say 6
{
  align(4):
  byte[3] b1; //offsetof=0, sizeof=3
  byte[3] b2; //offsetof=4, sizeof=3
}



Re: union.sizeof

2017-03-25 Thread zabruk70 via Digitalmars-d-learn

Thank you ag0aep6g and ketmar!!

I will use additional outside align.
I want packing inside, you are right.
But i check result size with assert() and failed.

But for clearness...
I was thinked, that align not changes SIZE, but changes LOCATION.
I was thinked, that "align(X) union Union1"
just force compiler to place Union1 on boundaries of X bytes...



union.sizeof

2017-03-25 Thread zabruk70 via Digitalmars-d-learn

//DMD 2.073.1 and latest 2.075.0-master-972eaed
//Windows 7 32-bit

union Union1
{
  align(1):
  byte[5] bytes5;
  struct
  {
align(1):
char char1;
uint int1;
  }
}

void main ()
{
  import std.stdio: writefln;
  writefln("Union1.sizeof=%d", Union1.sizeof);  //prints 8, not 5
}

I expect size of Union1 is 5 (5 bytes == char + uint == 5).
Is this my bug or DMD?
Can anybody reproduce?


Re: Newbie: can't manage some types...

2016-10-31 Thread zabruk70 via Digitalmars-d-learn

On Monday, 31 October 2016 at 16:06:48 UTC, Adam D. Ruppe wrote:


dmd yourfile.d winmm.lib



i personally like https://dlang.org/spec/pragma.html#lib

pragma(lib, "winmm.lib");


Re: full path to source file __FILE__

2016-07-21 Thread zabruk70 via Digitalmars-d-learn

On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote:

thisExePath won't work.


won't? what this means?

this work on my windows


import std.file: thisExePath;
import std.stdio: writeln;

void main()
{
  writeln(thisExePath());
}



Re: Is there a way to "see" source code generated by templates after a compile?

2016-07-17 Thread zabruk70 via Digitalmars-d-learn

On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:
If you want to see template expansions you have to wait a 
little longer.


Wow! Is this really possible?! So long time several peoples asked 
this...


Re: Properties don't work as expected

2016-07-05 Thread zabruk70 via Digitalmars-d-learn

On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote:

Property functions are used wrong by a compiler when it needs


i am sorry for my dumbness, what wrong with this code?

import std.stdio;

struct A {
@property ref int value() {
return value_;
}

@property void value(int v) {
value_ = v;
}

private:
int value_;
}

int main(string[] args) {
A a;
a.value = 10;
writeln(a.value);
a.value += 20;
writeln(a.value);
return 0;
}



Re: imports && -run [Bug?]

2016-05-13 Thread zabruk70 via Digitalmars-d-learn

On Friday, 13 May 2016 at 06:33:40 UTC, Jacob Carlborg wrote:
Even better is to use "rdmd" which will automatically track and 
compile dependencies.


but i should warn about annoing bug with local import
http://forum.dlang.org/post/mailman.1984.1373610213.13711.digitalmar...@puremagic.com
https://issues.dlang.org/show_bug.cgi?id=7016


Re: Is it legal to use std.windows modules?

2016-04-09 Thread zabruk70 via Digitalmars-d-learn

On Saturday, 9 April 2016 at 02:14:48 UTC, Jonathan M Davis wrote:

So, if anything, I'd open a bug report about how std.windows is


old bug
https://issues.dlang.org/show_bug.cgi?id=13516


Re: calculating CRC32

2016-04-08 Thread zabruk70 via Digitalmars-d-learn

print result as hex
try to xor result with 0x



Re: Is this rdmd bug or my fault ?

2016-01-16 Thread zabruk70 via Digitalmars-d-learn

Can anybody explain:

Is dependencies file produced from command:
dmd -deps=moduleA.deps moduleA.d
must contains mention of moduleC?
Is dependencies file produced reccursively?

Thanks.


Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]

2016-01-10 Thread zabruk70 via Digitalmars-d-learn

Hello.

1st Novice question:

i want function, operates sometimes with char[], sometimes with 
ubyte[].

internally it works with ubyte.
i can use overloading:

void myFunc(ubyte[] arg) {...};
void myFunc(char[] arg) { ubyte[] arg2 = cast(ubyte[]) arg; ...}

It is OK. But i want 2 params (arg1, arg2),
so i need write 4 overloading functions.

I fill templated needed, can anybody show me the way?


And 2nd question:

what if additionally to written above, function shuld return 
ubyte[] or char[] ?

can compiler guess what return type need from code?
something like:

char[] cc = myFunc()
ubyte[] bb = myFunc()

Thanks.


Re: Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]

2016-01-10 Thread zabruk70 via Digitalmars-d-learn

On Sunday, 10 January 2016 at 11:13:00 UTC, Tobi G. wrote:

ubyte[] myFunc(T1,T2)(T1[] a, T2[] b)


Tobi, big thanks!!!
I should learn templates...


Re: Function accepts const ubyte[], const char[], immutable ubyte[], immutable char[]

2016-01-10 Thread zabruk70 via Digitalmars-d-learn

On Sunday, 10 January 2016 at 14:17:28 UTC, Adam D. Ruppe wrote:

A `const(void)[]` type can accept any array as input. void[] is


Ah, how i can forget about void[] !
Thanks Adam!


Re: Is this rdmd bug or my fault ?

2016-01-09 Thread zabruk70 via Digitalmars-d-learn

On Friday, 8 January 2016 at 22:36:49 UTC, Tobi G. wrote:
On Saturday, 9 January 2016 at 01:43:57 UTC, Ivan Kazmenko wrote:

I get also a compilation error (with rdmd and -g).


Thanks Tobi and Ivan.
https://issues.dlang.org/show_bug.cgi?id=15533


Re: Convert a hex string into a ubyte[] or OutBuffer

2016-01-08 Thread zabruk70 via Digitalmars-d-learn

On Thursday, 7 January 2016 at 23:15:41 UTC, Basile B. wrote:

Damn, I've been trapped, thread exhumated from 2014 ...


Yes, but my post was made yesterday.
I don't want create new post and found this.
Thank you for your time.


Is this rdmd bug or my fault ?

2016-01-08 Thread zabruk70 via Digitalmars-d-learn

OS: Windows 7 (32 bit)
dmd: 2.069.2 and 2.070.0-b1

Then i used "-g" switch with RDMD, then i have OPTLINK error.
Reduced code, 3 modules, 2 of them in subdir:

moduleA.d
test\moduleB.d
test\moduleC.d

/
module moduleA;

public void funcA () {
  import test.moduleB: funcB;
  return;
}

void main(string[] args) {
  return;
}

/
module test.moduleB;

public void funcB () {
  import test.moduleC: funcC;
  funcC();

  return;
}

/
module test.moduleC;

public void funcC () {
  return;
}

/


C:\dmd2\windows\bin\rdmd.exe moduleA.d
//no errors, moduleA.exe created


C:\dmd2\windows\bin\rdmd.exe -g moduleA.d
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
C:\Users\user\AppData\Local\Temp\.rdmd\rdmd-moduleA.d-D3D7676836384146D1D9D907CF20EC26\objs\moduleA.exe.obj(moduleA.exe)
 Error 42: Symbol Undefined _D4test7moduleC5funcCFZv
--- errorlevel 1

Problem disappear, then i move import in test.modileB to global 
level:


/
module test.moduleB;

import test.moduleC: funcC;  //this works

public void funcB () {
  //import test.moduleC: funcC;  //this dont works
  funcC();

  return;
}
/


Should i create bugreport, or this is my mistake?


Re: Convert a hex string into a ubyte[] or OutBuffer

2016-01-07 Thread zabruk70 via Digitalmars-d-learn

Hello.
In modern phobos ver 2.069.1 exists template hexString

https://dlang.org/phobos/std_conv.html#.hexString

to convert hex string to bytes.
It works in compile time only.
But what if i need it in run time?

Is the answer in this topic still best way?
Or now we have some function/template in phobos?

Thanks.