def addstr(self, y, x, string, attr=None): # addstr(y, x, str[, attr]) and addstr(str[, attr])
        """ Wraps ncurses addstr in a try;except, prevents addstr from
            crashing cureses if it fails """
        if not attr:
            try:
                self.stdscr.addstr(y, x, string.encode(self.appState.charEncoding, 'replace'))
                #if self.appState.charEncoding == 'utf-8':
                #    self.stdscr.addstr(y, x, string.encode('utf-8'))
                #else:
                #    self.stdscr.addstr(y, x, string)
            except UnicodeEncodeError:
                # Replace non-ascii characters with ' '
                string = string.encode('ascii', 'replace').decode('ascii').replace('?', ' ')
                self.stdscr.addstr(y, x, string) 
            except curses.error:
                self.testWindowSize()
        else:
            try:
                self.stdscr.addstr(y, x, string.encode(self.appState.charEncoding, 'replace'), attr)
                #if self.appState.charEncoding == 'utf-8':
                #    self.stdscr.addstr(y, x, strng.encode('utf-8'), attr)
                #else:
                #    self.stdscr.addstr(y, x, string, attr)
            except UnicodeEncodeError:
                string = string.encode('ascii', 'replace').decode('ascii').replace('?', ' ')
                self.stdscr.addstr(y, x, string, attr)
            except curses.error:
                self.testWindowSize()
 Wraps ncurses addstr in a try;except, prevents addstr from
            crashing cureses if it fails 
durdraw/durdraw_ui_curses.py