Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Printing ASCII characters

Printing ASCII characters

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zeno   USA  (2,871 posts)  Bio
Date Mon 07 Mar 2005 02:31 AM (UTC)

Amended on Mon 07 Mar 2005 03:01 AM (UTC) by Zeno

Message
Is it possible to print ANSII characters with ch_printf? I read some posts how to type it so the MUD can handle it, but not displayed via the code. I want to display the Yen symbol, so I tried this:

    ch_printf( ch, "Test: %c", 157);


But it turned out like this:
Test: 

(If you can't view the above, it was a white rectangle box)

I'm pretty sure something like this is possible. I've seen ANSII characters on this GodWars MUD I played once, had like diamond, triangle and some other symbols.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Mon 07 Mar 2005 06:27 AM (UTC)
Message
IIRC, the MUDs tend to strip out characters from input and output that aren't 'printable' or something like that. You might want to check the functions that copy to the outgoing buffer or the functions that actually send it.

There is also the problem of signed vs. unsigned characters but that shouldn't make a huge difference.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #2 on Mon 07 Mar 2005 12:10 PM (UTC)

Amended on Mon 07 Mar 2005 12:12 PM (UTC) by Samson

Message
In comm.c you have in read_from_buffer a pair of calls that check to be sure what you're sending is printable. The calls to isascii and isprint govern what the mud will actually allow you to see.

The problem in removing this barrier is that not all clients treat the codes the same way. So while you're expecting to see a Yen symbol for 157, someone else may see a star, and still another may see a cent symbol. There's no real standardization on extended ascii yet.


Edit: And of course I read back and note that you meant WRITING to the buffer, not reading from it, although the reasoning still stands. The results are not predictable.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #3 on Mon 07 Mar 2005 05:26 PM (UTC)
Message
Quote:
There's no real standardization on extended ascii yet.
Really? I thought that all codes between 0 and 255 were standardized.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #4 on Mon 07 Mar 2005 05:43 PM (UTC)

Amended on Mon 07 Mar 2005 05:44 PM (UTC) by Zeno

Message
Is that right?
/*  Did not support ANSII  -Zeno
        if ( d->inbuf[i] == '\b' && k > 0 )
            --k;
        else if ( isascii(d->inbuf[i]) && isprint(d->inbuf[i]) )
            d->incomm[k++] = d->inbuf[i];
*/
        if ( d->inbuf[i] == '\b' && k > 0 )
            --k;
        else if (isprint(d->inbuf[i]))
            d->incomm[k++] = d->inbuf[i];


It doesn't seem to work.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #5 on Mon 07 Mar 2005 06:02 PM (UTC)

Amended on Mon 07 Mar 2005 07:54 PM (UTC) by Greven

Message
Well, according to the manpage
        isascii()
              checks whether c is a 7-bit unsigned char value that fits into the ASCII character set.  This function is a BSD extension and is also an SVID extension.

...

       isprint()
              checks for any printable character including space.
Assuming of course that the yen symbol is in fact in the ASCII character set, since I myself am not sure, there should be no reason that it stops that character. The isprint, however, my be stopping it. Have you tried removing both altogether, or just using isascii()?

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #6 on Mon 07 Mar 2005 07:08 PM (UTC)

Amended on Mon 07 Mar 2005 07:09 PM (UTC) by Zeno

Message
Well it does have the symbol:
http://www.cdrummond.qc.ca/cegep/informat/Professeurs/Alain/files/ascii.htm

Removing the isprint stops all commands to go through the MUD...

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #7 on Tue 08 Mar 2005 01:12 AM (UTC)
Message
Quote:

Really? I thought that all codes between 0 and 255 were standardized.


They are in the HTML standard. Sadly, they are not in ASCII. I've seen it enough from several different clients, and even different operating systems. You just never get the same results from program to program.
Top

Posted by Raz   (32 posts)  Bio
Date Reply #8 on Wed 09 Mar 2005 01:31 AM (UTC)
Message
Quote:
I'm pretty sure something like this is possible.


It entirely depends on the terminal that you are using. In standard Telnet (which is automatically the version you use), only 7-bit ASCII can be transferred and understood. No Telnet terminal is required to understand anything else. No Telnet terminal is required to have any certain definition of those odd characters you send to it. You could try to negotiate 8-bit ASCII mode, but thats a new can of worms since it is intended for binary transfers.

-Raz
C++ Wiki: http://danday.homelinux.org/dan/cppwiki/index.php
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #9 on Wed 09 Mar 2005 01:57 AM (UTC)
Message
I would assume, though, that most MUD clients would know how to handle this stuff; I don't think MUD clients make assumptions about 7-bit characters. And I think it's not too hefty of a requirement that people use clients other than telnet if they want to play these internationalized MUDs.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Raz   (32 posts)  Bio
Date Reply #10 on Wed 09 Mar 2005 04:01 AM (UTC)
Message
Quote:
There is also the problem of signed vs. unsigned characters but that shouldn't make a huge difference.


Why would there be a problem? Is the OP trying to play with raw data?

Quote:
I would assume, though, that most MUD clients would know how to handle this stuff


Windows-based clients may inherently be able to, but I wouldn't rely on such an assumption.

Quote:
I don't think MUD clients make assumptions about 7-bit characters.


No. I don't think many MUDs realize the old requirement about it. In this day and age, it is rather obsolete. However, all telnet applications must do 7-bit ASCII transfer until a request is made to do otherwise.

Back to the OP:

Quote:
I read some posts how to type it so the MUD can handle it, but not displayed via the code.


After going over the RFCs again, this might help you:
http://www.faqs.org/rfcs/rfc698.html
It allows safe negotiation with clients and servers about using extendend ASCII. I'm not sure of how many clients implement it, however.

-Raz
C++ Wiki: http://danday.homelinux.org/dan/cppwiki/index.php
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


29,198 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.