Unicode Terminal

Hello,

I recently started programming with ncurses on Linux.
Through experimenting with it, I found, that if the terminal doesn't support specific characters like the checkerboard pattern it prints "#" instead.
I thought, that ncurses is capable of telling whether a terminal supports unicode.

In case the terminal supports unicode I want to print the "Snowman_symbol" (\u2603) if not the character 'P'.
like this
1
2
3
4
5
if(TerimnalSupportsUnicode()){ //is there anything like the function inside the if-condition
   mvprintw(2, 2, "\u2603");
}else{
   mvprintw(2, 2, "P");
}


I already used various search engines, but I didn't find any answer.

Thanks in advance for your replies.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 ============================================================================
 Name        : forumc.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */
/*30th August, 2012
Abhishek Ghosh*/

#include<stdlib.h>
#include<stdio.h>

int
main ()
{
  int i;
  char *str = getenv ("LANG");

  for (i = 0; str[i + 2] != 00; i++)
    {
      if ((str[i] == 'u' && str[i + 1] == 't' && str[i + 2] == 'f')
          || (str[i] == 'U' && str[i + 1] == 'T' && str[i + 2] == 'F'))
        {
          printf
            ("Unicode is supported on this terminal and U+2603 is : \u2603");
          i = -1;
          break;
        }
    }

  if (i != -1)
    printf ("Unicode is not supported on this terminal.");

  return 0;
}
Topic archived. No new replies allowed.