digitalmars.D.learn - isatty and Pavel stream.d
- carlos smith (11/11) May 01 2009 Hi!,
- Jarrett Billingsley (10/19) May 01 2009 isatty(). You can use any C function from D. Phobos does not have a
- Carlos Smith (23/35) May 01 2009 It worked fine.no link error.
- Jarrett Billingsley (7/18) May 01 2009 I have no idea.
- Georg Wrede (14/64) May 03 2009 Assuming you only want to know if the program is used on a console, or
Hi!, What's the equivalent of the C isatty() in D? I grepped isatty in all sources files and did not find it. Also, i would like to know if anyone compiled the Pavel's stream.d library with a recent V1 D compiler. This library seems to allow reading utf-8 from a windows console. With dmd 1.043, it's very easy to write utf string to console. But, how do we readln from the console ? Thanks...
May 01 2009
On Fri, May 1, 2009 at 10:41 AM, carlos smith <carlos-smith sympatico.ca> wrote:Hi!, What's the equivalent of the C isatty() in D? I grepped isatty in all sources files and did not find it.isatty(). You can use any C function from D. Phobos does not have a terribly good set of Posix headers, so you'll have to declare it yourself: extern(C) int isatty(int); And you should be able to use it. You shouldn't get any linking errors, at least I don't think.Also, i would like to know if anyone compiled the Pavel's stream.d library with a recent V1 D compiler.You mean std.stream? That's been part of Phobos .. well, forever. At least 5 years anyway.This library seems to allow reading utf-8 from a windows console. With dmd 1.043, it's very easy to write utf string to console. But, how do we readln from the console ?std.stdio.readln.
May 01 2009
"Jarrett Billingsley" <jarrett.billingsley gmail.com> a écrit dans le message de >extern(C) int isatty(int); And you should be able to use it. You shouldn't get any linking errors, at least I don't think.It worked fine.no link error. isatty is sometimes used like this: isatty(fileno(fp)) So i used fileno(), whis is declared in std.c.stdio. but i got a linking error: _fileno not found. I tried two other function in std.c.stdio to see if this was causes by some other factor i am not awared of. clearerr() and rewind() works just fine. So may be there is a problem with fileno() ??You mean std.stream? That's been part of Phobos .. well, forever. At least 5 years anyway.No, i mean the stream.d that comes in stream.zip from the Pavel's site: http://int19h.tamb.ru/files/stream.zip His stream library seems different. as, it have functions to read Unicode strings from the console. I tried to compile it with dmd 1.043 but there are many errors.This library seems to allow reading utf-8 from a windows console. With dmd 1.043, it's very easy to write utf string to console. But, how do we readln from the console ?I know that function. But it allows to read char[] arrays only. (if i read well the declarations). How do i read wchar[] arrays from the console with it ? As i said, it's real easy to write unicode strings to the console. But, it seems a lot less easier to read unicode from the console. Am i right ?std.stdio.readln
May 01 2009
On Fri, May 1, 2009 at 11:52 AM, Carlos Smith <carlos-smith sympatico.ca> w= rote:So may be there is a problem with fileno() ??I have no idea.std.stream *is* Pavel's code. That zip is absolutely ancient. It's no surprise it doesn't compile.You mean std.stream? =A0That's been part of Phobos .. well, forever. At least 5 years anyway.No, i mean the stream.d that comes in stream.zip from the Pavel's site: http://int19h.tamb.ru/files/stream.zip His stream library seems different. as, it have functions to read Unicode strings from the console. I tried to compile it with dmd 1.043 but there are many errors.I know that function. But it allows to read char[] arrays only. (if i read well the declarations).Sure, but char[] IS Unicode! It's just UTF-8.How do i read wchar[] arrays from the console with it ?Use std.cstream.din.readLineW() if you want a wchar[] so badly.
May 01 2009
Carlos Smith wrote:"Jarrett Billingsley" <jarrett.billingsley gmail.com> a écrit dans le message de >Assuming you only want to know if the program is used on a console, or if input, output, or error are redirected, then this helps: import std.stdio; extern(C) int isatty(int); void main() { writeln("input from tty is ", isatty(0)?"true":"false"); writeln("output to tty is ", isatty(1)?"true":"false"); writeln("error to tty is ", isatty(2)?"true":"false"); }extern(C) int isatty(int); And you should be able to use it. You shouldn't get any linking errors, at least I don't think.It worked fine.no link error. isatty is sometimes used like this: isatty(fileno(fp)) So i used fileno(), whis is declared in std.c.stdio. but i got a linking error: _fileno not found.I tried two other function in std.c.stdio to see if this was causes by some other factor i am not awared of. clearerr() and rewind() works just fine. So may be there is a problem with fileno() ??As posted in recent thread "How-to: input/output "Japanese Caracters", all you have to do with Unicode is simply to use readln and writeln. They have been Unicode-proof since a bunch of years back.You mean std.stream? That's been part of Phobos .. well, forever. At least 5 years anyway.No, i mean the stream.d that comes in stream.zip from the Pavel's site: http://int19h.tamb.ru/files/stream.zip His stream library seems different. as, it have functions to read Unicode strings from the console. I tried to compile it with dmd 1.043 but there are many errors.This library seems to allow reading utf-8 from a windows console. With dmd 1.043, it's very easy to write utf string to console. But, how do we readln from the console ?I know that function. But it allows to read char[] arrays only. (if i read well the declarations). How do i read wchar[] arrays from the console with it ? As i said, it's real easy to write unicode strings to the console. But, it seems a lot less easier to read unicode from the console. Am i right ?std.stdio.readln
May 03 2009