Thread overview
How make wsatring or dstring default for string and literals?
Feb 24, 2020
Marcone
Feb 24, 2020
Adam D. Ruppe
Feb 24, 2020
Marcone
Feb 24, 2020
Adam D. Ruppe
February 24, 2020
I live in Brazil and speak português brasileiro and need make programs that is good with words like ã, á, ç, ê, etc. How can I make wstring or dstring default for string and literals? I don't want to explicit this every time.
February 24, 2020
On Monday, 24 February 2020 at 19:27:04 UTC, Marcone wrote:
> I live in Brazil and speak português brasileiro and need make programs that is good with words like ã, á, ç, ê, etc.

Regular string works with those just fine too.
February 24, 2020
On Monday, 24 February 2020 at 19:28:43 UTC, Adam D. Ruppe wrote:
> On Monday, 24 February 2020 at 19:27:04 UTC, Marcone wrote:
>> I live in Brazil and speak português brasileiro and need make programs that is good with words like ã, á, ç, ê, etc.
>
> Regular string works with those just fine too.

	foreach(i; "Canção")
	{
		writeln(i);
	}
Prints:

C
a
n
�
�
�
�
o
February 24, 2020
On Monday, 24 February 2020 at 21:25:50 UTC, Marcone wrote:
> 	foreach(i; "Canção")
> Prints:

Try

foreach(dchar i; "Canção") // note the added dchar

to see a different presentation of the very same data.

If you take the strings apart byte by byte that will look different, but they all represent the same characters, and foreach can help decode that if you ask it to.