isgraph


function template
<locale>
template <class charT>
  bool isgraph ( charT c, const locale& loc );

Check if character has graphical representation using locale

Checks whether c is has graphical representation using ctype facet of locale loc, returning the same as a call to:

 
use_facet < ctype<charT> > (loc).is (ctype_base::graph, c)


This function replicates the functionality of its C-library equivalent isgraph. See isgraph for more info.

Parameters

c
Character to be checked.
loc
Locale to be used. Shall have facet ctype present.


Template parameter charT is the character type.

Return Value

true if indeed c has graphical representation, false otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// isgraph example (C++)
#include <iostream>
#include <fstream>
#include <string>
#include <locale>
using namespace std;

int main ()
{
  locale loc;
  ifstream myfile ("myfile.txt");
  char c;
  while (myfile.good())
  {
    myfile >> c;
    if ( isgraph(c,loc) ) cout << c;
  }
  myfile.close();
  return 0;
}


This example prints out the contents of myfile.txt without spaces and special characters, i.e. only prints out the characters that qualify as isgraph.

See also