digitalmars.D.learn - Language Support - Read and Write
- Siavash Babaei (2/2) Dec 15 2013 Is it not possible to read and write in non-latin languages like
- qznc (6/8) Dec 15 2013 D source files are UTF-8. You can name your variables and
- Siavash Babaei (5/5) Dec 15 2013 Yes and No: I kind of knew that and just wanted to make sure.
- Philippe Sigaud (5/5) Dec 15 2013 FWIW, on my box (Kubuntu, 32bits), without changing anything in my confi...
- Siavash Babaei (2/2) Dec 16 2013 I am using Windows 7 Ultimate x64. Maybe PowerShell will do the
- Marco Leise (26/31) Dec 15 2013 o output it=20
Is it not possible to read and write in non-latin languages like Hebrew, Arabic, Farsi, etc?! If so, how, and if not, why?
Dec 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?
Dec 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.
Dec 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?
Dec 15 2013
I am using Windows 7 Ultimate x64. Maybe PowerShell will do the trick!
Dec 16 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.=20 Thank you for confirming it. On the other hand, when I define a=20 string variable and set it to say, "=D8=B3=D9=84=D8=A7=D9=85", and want t=o output it=20to the CMD (write, writeln, writef), what I get is gibberish and=20 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-en= coding-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. --=20 Marco
Dec 15 2013