Compartilhar via


isxdigit

Tests whether an element in a locale is a character used to represent a hexadecimal number.

template<Class CharType> 
   bool isxdigit( 
      CharType _Ch,  
      const locale& _Loc 
   )

Parameters

  • _Ch
    The element to be tested.

  • _Loc
    The locale containing the element to be tested.

Return Value

true if the element tested is a character used to represent a hexadecimal number; false if it is not.

Remarks

The template function returns use_facet<ctype< CharType> >(_Loc).is(ctype<CharType>::xdigit, _Ch).

Hexadecimal digits use base 16 to represent numbers, using the numbers 0 through 9 plus case-insensitive letters A through F to represent the decimal numbers 0 through 15.

Example

// locale_isxdigit.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>

using namespace std;

int main( )   
{
   locale loc ( "German_Germany" );
   bool result1 = isxdigit ( '5', loc );
   bool result2 = isxdigit ( 'd', loc );
   bool result3 = isxdigit ( 'q', loc );

   if ( result1 )
      cout << "The character '5' in the locale is "
           << "a hexidecimal digit-character." << endl;
   else
      cout << "The character '5' in the locale is "
           << " not a hexidecimal digit-character." << endl;

   if ( result2 )
      cout << "The character 'd' in the locale is "
           << "a hexidecimal digit-character." << endl;
   else
      cout << "The character 'd' in the locale is "
           << " not a hexidecimal digit-character." << endl;

   if ( result3 )
      cout << "The character 'q' in the locale is "
           << "a hexidecimal digit-character." << endl;
   else
      cout << "The character 'q' in the locale is "
           << " not a hexidecimal digit-character." << endl;
}

Output

The character '5' in the locale is a hexidecimal digit-character.
The character 'd' in the locale is a hexidecimal digit-character.
The character 'q' in the locale is  not a hexidecimal digit-character.

Requirements

Header: <locale>

Namespace: std