Thread overview
Language Support - Read and Write
Dec 15, 2013
Siavash Babaei
Dec 15, 2013
qznc
Dec 15, 2013
Siavash Babaei
Dec 15, 2013
Philippe Sigaud
Dec 16, 2013
Siavash Babaei
Dec 15, 2013
Marco Leise
December 15, 2013
Is it not possible to read and write in non-latin languages like Hebrew, Arabic, Farsi, etc?! If so, how, and if not, why?
December 15, 2013
On Sunday, 15 December 2013 at 08:41:42 UTC, Siavash Babaei wrote:
> Is it not possible to read and write in non-latin languages like Hebrew, Arabic, Farsi, etc?! If so, how, and if not, why?

D source files are UTF-8. You can name your variables and functions using the fullw wealth of Unicode.

D provides the string type (and others) for Unicode data.

D has no problem with Hebrew, Arabic, Farsi, etc.

Does that answer your question?
December 15, 2013
Yes and No: I kind of knew that and just wanted to make sure. Thank you for confirming it. On the other hand, when I define a string variable and set it to say, "سلام", and want to output it to the CMD (write, writeln, writef), what I get is gibberish and CMD is set correctly BTW.
December 15, 2013
FWIW, on my box (Kubuntu, 32bits), without changing anything in my config.

auto s = "سلام";
writeln(s);

Prints the string correctly at the command line (exact same chars).

What OS are you using?

December 15, 2013
Am Sun, 15 Dec 2013 11:19:43 +0100
schrieb "Siavash Babaei" <siavash.babaei@gmail.com>:

> Yes and No: I kind of knew that and just wanted to make sure. Thank you for confirming it. On the other hand, when I define a string variable and set it to say, "سلام", and want to output it to the CMD (write, writeln, writef), what I get is gibberish and CMD is set correctly BTW.

If you use an older version of Windows you might have to change
the console font to "Lucida" I think it was to support a wider
range of characters.
Then there is a reason why Java has a complicated encoding
system for console output. While on Linux the console uses
UTF-8 (in line with D) for a few years now, the Windows
console usually expects Latin-1 or UTF-16. writeln() doesn't
take this into consideration and I had issues even with German
umlauts on Windows. It worked best when I used the Windows API
directly to write UTF-16 to the console, prefixed with a
byte-order-mark. That together with switching the console font
to Lucida, should give you proper printing of non-ASCII
characters.

If this sounds overly complicated, take a look at Java: http://stackoverflow.com/questions/2415597/java-how-to-detect-and-change-encoding-of-system-console

The result is different on Windows, Linux and even Mac unless you work closely with the specific console implementation of the operating system. A general "writeln" doesn't cut it unless you are on Linux or write to files or "pipe" the output to another program understanding UTF-8.

-- 
Marco

December 16, 2013
I am using Windows 7 Ultimate x64. Maybe PowerShell will do the trick!