Extended ASCII graphics

Help
2006-11-20
2013-04-25
  • Brad Kartchner

    Brad Kartchner - 2006-11-20

    I'm having trouble getting PDCURSES to display non-standard ASCII characters using addch (). 

    Specifically, I'm trying to use some of the line-drawing characters.  When I attempt to draw them with addch (), pdcurses displays a blank space.  This occurs whether I try to use the ASCII code (ie: addch (196)) or the curses definitions (ie: addch (ACS_HLINE)).  I've checked the A_ALTCHARSET attribute and it appears to be set.  I CAN get these line-drawing characters to appear if I use the line-drawing functions (hline () or vline ()), so I know it can be done.  However, I need to use the addch () function rather than hline () or vline ().

    I'm compiling for Windows XP (command console) and have had the same problem with Windows 2005 Express as well as Dev-Cpp (Mingw compiler).

    Any suggestions?  (No, "get lost" doesn't count)

     
    • William McBrine

      William McBrine - 2006-11-21

      I won't say "get lost", but I have to say "works for me". Maybe you could post a complete example non-working program?

       
    • Brad Kartchner

      Brad Kartchner - 2006-11-21

      Hmmmm...  I just coded up a quick sample program and the extended ASCII graphics work fine. 

      I appologize.  That should have been my first step before posting here.

      I'll go through the problematic program and see if I can determine what's going on. 

      Thanks for the response!

       
    • Brad Kartchner

      Brad Kartchner - 2006-11-21

      Just to follow-up, in case it helps anyone else.

      I created an 'IO' class to serve as a wrapper around the pdcurses library functions.  To display a character on screen, I defined a member function called 'PutChar ()', which then calls the pdcurses function 'addch ()'.  However, I define my 'PutChar ()' function to take a parameter of type 'char'.  It appears that pdcurses needs more bits in order to display extended graphics characters.  I changed the function to take a parameter of type 'unsigned int', and viola! everything is being displayed properly.

      Thanks again!

       
    • William McBrine

      William McBrine - 2006-11-21

      It's not the number of bits; it's the unwanted sign extension you got when you implicitly promoted a signed char to a chtype (which is an unsigned long, short, or int, depending on the system -- usually long).

      Changing the PutChar() parameter to unsigned char, or (my choice) casting the parameter to unsigned char in the call to addch(), should work just as well. That is:

      void io::PutChar(char c)
      {
          addch((unsigned char)c);
      }

      or whatever.

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks