www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - I can ask questions about dmd on windows here in this forum?

reply "Cassio Butrico" <cassio_butrico ig.com.br> writes:
I'm new to this language, and I wonder if I will have some 
support simple questions.
Thank you for your attention.
Aug 30 2014
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Sunday, 31 August 2014 at 03:16:38 UTC, Cassio Butrico wrote:
 I'm new to this language, and I wonder if I will have some 
 support simple questions.
 Thank you for your attention.
Yes.
Aug 30 2014
parent reply "Cassio Butrico" <cassio_butrico ig.com.br> writes:
On Sunday, 31 August 2014 at 03:20:00 UTC, Vladimir Panteleev 
wrote:
 On Sunday, 31 August 2014 at 03:16:38 UTC, Cassio Butrico wrote:
 I'm new to this language, and I wonder if I will have some 
 support simple questions.
 Thank you for your attention.
Yes.
My question is about wstring and dstring, which and the best way to input data, converting and which should I use
Aug 30 2014
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 08/30/2014 08:37 PM, Cassio Butrico wrote:

 My question is about wstring and dstring,
 which and the best way to input data, converting and which should I use
Unless there is a specific reason not to, use 'string'. When you really need random access to characters, then use 'dstring'. To input data, readf() is for formatted input: int i; readf(" %s", &i); When reading a whole line as a string, consider import std.stdio; import std.string; // ... string line = chomp(readln()); Ali
Aug 30 2014
next sibling parent reply "Cassio Butrico" <cassio_butrico ig.com.br> writes:
On Sunday, 31 August 2014 at 05:27:15 UTC, Ali Çehreli wrote:
 On 08/30/2014 08:37 PM, Cassio Butrico wrote:

 My question is about wstring and dstring,
 which and the best way to input data, converting and which
should I use Unless there is a specific reason not to, use 'string'. When you really need random access to characters, then use 'dstring'. To input data, readf() is for formatted input: int i; readf(" %s", &i); When reading a whole line as a string, consider import std.stdio; import std.string; // ... string line = chomp(readln()); Ali
Thanks so much for answering me. I was having trouble setting on my terminal in windows, I'm still trying to solve.
Aug 30 2014
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 08/30/2014 10:37 PM, Cassio Butrico wrote:

 I was having trouble setting on my terminal in windows, I'm still trying
 to solve.
In addition to what Vladimir Panteleev said, you should also select a Unicode font for your terminal like Lucida Console. Basically: 1) Set the code page to 65001 by chcp 65001 2) Select a Unicode font from the console window's menu. You can set those two for the entire system. (I don't remember how.) As Vladimir Panteleev said, you can set both of those from inside each program as well. Ali
Aug 30 2014
parent "Cassio Butrico" <cassio_butrico ig.com.br> writes:
On Sunday, 31 August 2014 at 06:08:46 UTC, Ali Çehreli wrote:
 On 08/30/2014 10:37 PM, Cassio Butrico wrote:

 I was having trouble setting on my terminal in windows, I'm 
 still trying
 to solve.
In addition to what Vladimir Panteleev said, you should also select a Unicode font for your terminal like Lucida Console. Basically: 1) Set the code page to 65001 by chcp 65001 2) Select a Unicode font from the console window's menu. You can set those two for the entire system. (I don't remember how.) As Vladimir Panteleev said, you can set both of those from inside each program as well. Ali
Ali Çehreli you is very attentive, answering for me. I do not know how to use SetConsoleCP or SetConsoleOutputCP on a progrtama in d. I'll try to find out.
Aug 30 2014
prev sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Ali Çehreli:

 Unless there is a specific reason not to, use 'string'. When 
 you really need random access to characters, then use 'dstring'.
So are the use cases for wstring limited? Bye, bearophile
Aug 31 2014
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 08/31/2014 12:37 AM, bearophile wrote:
 Ali Çehreli:

 Unless there is a specific reason not to, use 'string'. When you
 really need random access to characters, then use 'dstring'.
So are the use cases for wstring limited? Bye, bearophile
Yes, without real experience, I am under that impression. Let's see: - char is UTF-8. UTF-8 is a variable-length encoding, from 1 up to 6 bytes per character. - wchar is UTF-16. UTF-16 is a variable-length encoding, 2 or 4 bytes per character. - dchar is UTF-32. UTF-32 is a fixed-length encoding, exactly 4 bytes per characters. As I understand it, wchar would make sense when UTF-8 would take considerably more space than UTF-16 for a given text. Another case is when a wchar array is guaranteed to consist solely of 2-byte characters; it can then safely be used as a random access range. In contrast, a dchar array provides random access for any text but takes up more space for certain text than UTF-8 and UTF-16 (e.g. text consisting mostly of 1-byte characters in UTF-8 (e.g. ASCII)). So yes, wchar has limited use compared to the others. Ali
Aug 31 2014
parent reply Jonathan M Davis via Digitalmars-d-learn writes:
On Sun, 31 Aug 2014 01:11:02 -0700
Ali Çehreli via Digitalmars-d-learn <digitalmars-d-learn puremagic.com>
wrote:

 On 08/31/2014 12:37 AM, bearophile wrote:
 Ali Çehreli:

 Unless there is a specific reason not to, use 'string'. When you
 really need random access to characters, then use 'dstring'.
So are the use cases for wstring limited? Bye, bearophile
Yes, without real experience, I am under that impression. Let's see: - char is UTF-8. UTF-8 is a variable-length encoding, from 1 up to 6 bytes per character. - wchar is UTF-16. UTF-16 is a variable-length encoding, 2 or 4 bytes per character. - dchar is UTF-32. UTF-32 is a fixed-length encoding, exactly 4 bytes per characters. As I understand it, wchar would make sense when UTF-8 would take considerably more space than UTF-16 for a given text. Another case is when a wchar array is guaranteed to consist solely of 2-byte characters; it can then safely be used as a random access range. In contrast, a dchar array provides random access for any text but takes up more space for certain text than UTF-8 and UTF-16 (e.g. text consisting mostly of 1-byte characters in UTF-8 (e.g. ASCII)). So yes, wchar has limited use compared to the others.
The main use case for an array of wchar is to interact with Windows functions which use UTF-16. There may be rare cases to use it otherwise, but the average D program should just use string unless it needs random-access, in which case, it should use dstring. wstring is ultimately of marginal use. - Jonathan M Davis
Aug 31 2014
parent reply "Kagamin" <spam here.lot> writes:
On Sunday, 31 August 2014 at 08:37:40 UTC, Jonathan M Davis via 
Digitalmars-d-learn wrote:
 D program should just use string unless it needs random-access, 
 in which case,
 it should use dstring.
Except that dstring is not fool-proof either when one needs to work at grapheme level.
Sep 02 2014
parent reply "Cassio Butrico" <cassio_butrico ig.com.br> writes:
On Tuesday, 2 September 2014 at 16:49:15 UTC, Kagamin wrote:
 On Sunday, 31 August 2014 at 08:37:40 UTC, Jonathan M Davis via 
 Digitalmars-d-learn wrote:
 D program should just use string unless it needs 
 random-access, in which case,
 it should use dstring.
Except that dstring is not fool-proof either when one needs to work at grapheme level.
I'm actually learning it because I'm sure is a beautiful and easy language learning programs, so the time that there was no gui. the micros. saidades got me my TRS-80 when programmed in pascal and cobol.
Sep 02 2014
parent "Cassio Butrico" <cassio_butrico ig.com.br> writes:
On Tuesday, 2 September 2014 at 20:12:12 UTC, Cassio Butrico 
wrote:
 On Tuesday, 2 September 2014 at 16:49:15 UTC, Kagamin wrote:
 On Sunday, 31 August 2014 at 08:37:40 UTC, Jonathan M Davis 
 via Digitalmars-d-learn wrote:
 D program should just use string unless it needs 
 random-access, in which case,
 it should use dstring.
Except that dstring is not fool-proof either when one needs to work at grapheme level.
I'm actually learning it because I'm sure is a beautiful and easy language learning programs, so the time that there was no gui. the micros. saidades got me my TRS-80 when programmed in pascal and cobol.
I miss me my TRS-80 when programmed in pascal and cobol. sorry hehe :)
Sep 02 2014