unget_wch of non-8bit chars

View: New views
1 Messages — Rating Filter:   Alert me  

unget_wch of non-8bit chars

by Mike Gran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi-

With using libncursesw from ncurses-5.7-20090808 on i686-pc-linux-gnu, I
tried to unget_wch characters then retrieve them using getn_wstr.  While
that seems to work for ASCII characters, it doesn't work for non-Latin-1
characters, apparently.

I've attached a sample program where I've tried to do that.  I unget a
newline and U+017C and try to retrieve it with getn_wstr.  getn_wstr
returns OK, and the resulting string from getn_wstr is a null string.

Thanks,

Mike Gran

 

[r039_get_wstr.c]

/* -*- coding: utf-8 -*- */
#define _XOPEN_SOURCE_EXTENDED
#include <curses.h>
#include <locale.h>
#include <stdio.h>
#include <wchar.h>

int main (int argc, char ** argv)
{
  wint_t buf[10];
  int ret;
  size_t i;

  setlocale (LC_ALL, "");
  initscr ();
  unget_wch (L'\n');
  unget_wch (L'ż');         /*  LATIN SMALL LETTER Z WITH DOT ABOVE */
  /* unget_wch (L'z'); */   /*  LATIN SMALL LETTER Z */
  ret = getn_wstr (buf, 10);
  endwin ();

  if (ret == OK)
    printf ("OK\n");
  else if (ret == ERR)
    printf ("ERR\n");
  else
    printf ("???\n");

  i = 0;
  while (1)
    {
      printf ("i %d wint %d\n", i, buf[i]);
      if (buf[i] == 0)
        break;
      i++;
    }
 
  return 1;
}



_______________________________________________
Bug-ncurses mailing list
Bug-ncurses@...
http://lists.gnu.org/mailman/listinfo/bug-ncurses