Udostępnij za pośrednictwem


<locale>, funkcje

has_facet
isalnum
isalpha
iscntrl
Isdigit
isgraph
Islower
isprint
ispunct
isspace
Isupper
isxdigit
Tolower
Toupper
Use_facet

has_facet

Sprawdza, czy określony zestaw reguł jest przechowywany w określonych ustawieniach regionalnych.

template <class Facet>
bool has_facet(const locale& Loc);

Parametry

Loc
Ustawienia regionalne do przetestowania pod kątem obecności aspektu.

Wartość zwracana

true jeśli ustawienia regionalne mają aspekt testowany dla; false jeśli tak nie jest.

Uwagi

Funkcja szablonu jest przydatna do sprawdzania, czy niemandacyjne aspekty są wyświetlane w ustawieniach regionalnych przed use_facet wywołaniami, aby uniknąć wyjątku, który byłby zgłaszany, gdyby nie był obecny.

Przykład

// locale_has_facet.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result = has_facet <ctype<char> > ( loc );
   cout << result << endl;
}
1

isalnum

Sprawdza, czy element w ustawieniach regionalnych jest znakiem alfabetycznym czy liczbowym.

template <class CharType>
bool isalnum(CharType Ch, const locale& Loc)

Parametry

Ch
Element alfanumeryczny do przetestowania.

Loc
Ustawienia regionalne zawierające element alfanumeryczny do przetestowania.

Wartość zwracana

true jeśli testowany element jest alfanumeryczny; false jeśli tak nie jest.

Przykład

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

using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result1 = isalnum ( 'L', loc);
   bool result2 = isalnum ( '@', loc);
   bool result3 = isalnum ( '3', loc);

   if ( result1 )
      cout << "The character 'L' in the locale is "
           << "alphanumeric." << endl;
   else
      cout << "The character 'L' in the locale is "
           << " not alphanumeric." << endl;

   if ( result2 )
      cout << "The character '@' in the locale is "
           << "alphanumeric." << endl;
   else
      cout << "The character '@' in the locale is "
           << " not alphanumeric." << endl;

   if ( result3 )
      cout << "The character '3' in the locale is "
           << "alphanumeric." << endl;
   else
      cout << "The character '3' in the locale is "
           << " not alphanumeric." << endl;
}
The character 'L' in the locale is alphanumeric.
The character '@' in the locale is  not alphanumeric.
The character '3' in the locale is alphanumeric.

isalpha

Sprawdza, czy element w ustawieniach regionalnych jest znakiem alfabetycznym.

template <class CharType>
bool isalpha(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element alfabetyczny do przetestowania.

Wartość zwracana

true jeśli testowany element jest alfabetyczny; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype<CharType>:: alpha, Ch).

Przykład

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

using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result1 = isalpha ( 'L', loc);
   bool result2 = isalpha ( '@', loc);
   bool result3 = isalpha ( '3', loc);

   if ( result1 )
      cout << "The character 'L' in the locale is "
           << "alphabetic." << endl;
   else
      cout << "The character 'L' in the locale is "
           << " not alphabetic." << endl;

   if ( result2 )
      cout << "The character '@' in the locale is "
           << "alphabetic." << endl;
   else
      cout << "The character '@' in the locale is "
           << " not alphabetic." << endl;

   if ( result3 )
      cout << "The character '3' in the locale is "
           << "alphabetic." << endl;
   else
      cout << "The character '3' in the locale is "
           << " not alphabetic." << endl;
}

iscntrl

Sprawdza, czy element w ustawieniach regionalnych jest znakiem kontrolnym.

template <class CharType>
bool iscntrl(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element do przetestowania.

Wartość zwracana

true jeśli testowany element jest znakiem kontrolnym; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype CharType><:: cntrl, ). Ch

Przykład

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

using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result1 = iscntrl ( 'L', loc );
   bool result2 = iscntrl ( '\n', loc );
   bool result3 = iscntrl ( '\t', loc );

   if ( result1 )
      cout << "The character 'L' in the locale is "
           << "a control character." << endl;
   else
      cout << "The character 'L' in the locale is "
           << " not a control character." << endl;

   if ( result2 )
      cout << "The character-set 'backslash-n' in the locale\n is "
           << "a control character." << endl;
   else
      cout << "The character-set 'backslash-n' in the locale\n is "
           << " not a control character." << endl;

   if ( result3 )
      cout << "The character-set 'backslash-t' in the locale\n is "
           << "a control character." << endl;
   else
      cout << "The character-set 'backslash-n' in the locale \n is "
           << " not a control character." << endl;
}

Isdigit

Sprawdza, czy element w ustawieniach regionalnych jest znakiem liczbowym.

template <class CharType>
bool isdigit(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element do przetestowania.

Wartość zwracana

true jeśli testowany element jest znakiem liczbowym; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype<CharType>:: digit, Ch).

Przykład

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

using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result1 = isdigit ( 'L', loc );
   bool result2 = isdigit ( '@', loc );
   bool result3 = isdigit ( '3', loc );

   if ( result1 )
      cout << "The character 'L' in the locale is "
           << "a numeric character." << endl;
   else
      cout << "The character 'L' in the locale is "
           << " not a numeric character." << endl;

   if ( result2 )
      cout << "The character '@' in the locale is "
           << "a numeric character." << endl;
   else
      cout << "The character '@' in the locale is "
           << " not a numeric character." << endl;

   if ( result3 )
      cout << "The character '3' in the locale is "
           << "a numeric character." << endl;
   else
      cout << "The character '3' in the locale is "
           << " not a numeric character." << endl;
}

isgraph

Sprawdza, czy element w ustawieniach regionalnych jest znakiem alfanumerycznym lub interpunkcyjnym.

template <class CharType>
bool isgraph(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element do przetestowania.

Wartość zwracana

true jeśli testowany element jest znakiem alfanumerycznym lub znakiem interpunkcyjnym; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype<CharType>:: graph, Ch).

Przykład

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

using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result1 = isgraph ( 'L', loc );
   bool result2 = isgraph ( '\t', loc );
   bool result3 = isgraph ( '.', loc );

   if ( result1 )
      cout << "The character 'L' in the locale is\n "
           << "an alphanumeric or punctuation character." << endl;
   else
      cout << "The character 'L' in the locale is\n "
           << " not an alphanumeric or punctuation character." << endl;

   if ( result2 )
      cout << "The character 'backslash-t' in the locale is\n "
           << "an alphanumeric or punctuation character." << endl;
   else
      cout << "The character 'backslash-t' in the locale is\n "
           << "not an alphanumeric or punctuation character." << endl;

   if ( result3 )
      cout << "The character '.' in the locale is\n "
           << "an alphanumeric or punctuation character." << endl;
   else
      cout << "The character '.' in the locale is\n "
           << " not an alphanumeric or punctuation character." << endl;
}

Islower

Sprawdza, czy element w ustawieniach regionalnych jest pisany małymi literami.

template <class CharType>
bool islower(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element do przetestowania.

Wartość zwracana

true jeśli testowany element jest małym znakiem; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype<CharType>:: lower, Ch).

Przykład

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

using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result1 = islower ( 'L', loc );
   bool result2 = islower ( 'n', loc );
   bool result3 = islower ( '3', loc );

   if ( result1 )
      cout << "The character 'L' in the locale is "
           << "a lowercase character." << endl;
   else
      cout << "The character 'L' in the locale is "
           << " not a lowercase character." << endl;

   if ( result2 )
      cout << "The character 'n' in the locale is "
           << "a lowercase character." << endl;
   else
      cout << "The character 'n' in the locale is "
           << " not a lowercase character." << endl;

   if ( result3 )
      cout << "The character '3' in the locale is "
           << "a lowercase character." << endl;
   else
      cout << "The character '3' in the locale is "
           << " not a lowercase character." << endl;
}

isprint

Sprawdza, czy element w ustawieniach regionalnych jest znakiem drukowalnym.

template <class CharType>
bool isprint(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element do przetestowania.

Wartość zwracana

true jeśli testowany element jest drukowalny; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype<CharType>:: print, Ch).

Przykład

// locale_isprint.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
using namespace std;

int main( )
{
   locale loc ( "German_Germany" );

   bool result1 = isprint ( 'L', loc );
   if ( result1 )
      cout << "The character 'L' in the locale is "
           << "a printable character." << endl;
   else
      cout << "The character 'L' in the locale is "
           << " not a printable character." << endl;

   bool result2 = isprint( '\t', loc );
   if ( result2 )
      cout << "The character 'backslash-t' in the locale is "
           << "a printable character." << endl;
   else
      cout << "The character 'backslash-t' in the locale is "
           << " not a printable character." << endl;

   bool result3 = isprint( '\n', loc );
   if ( result3 )
      cout << "The character 'backslash-n' in the locale is "
           << "a printable character." << endl;
   else
      cout << "The character 'backslash-n' in the locale is "
           << " not a printable character." << endl;
}

ispunct

Sprawdza, czy element w ustawieniach regionalnych jest znakiem interpunkcyjnym.

template <class CharType>
bool ispunct(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element do przetestowania.

Wartość zwracana

true jeśli testowany element jest znakiem interpunkcyjnym; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype<CharType>:: interpunkcyjny, Ch).

Przykład

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

using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result1 = ispunct ( 'L', loc );
   bool result2 = ispunct ( ';', loc );
   bool result3 = ispunct ( '*', loc );

   if ( result1 )
      cout << "The character 'L' in the locale is "
           << "a punctuation character." << endl;
   else
      cout << "The character 'L' in the locale is "
           << " not a punctuation character." << endl;

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

   if ( result3 )
      cout << "The character '*' in the locale is "
           << "a punctuation character." << endl;
   else
      cout << "The character '*' in the locale is "
           << " not a punctuation character." << endl;
}

isspace

Sprawdza, czy element w ustawieniach regionalnych jest znakiem białym.

template <class CharType>
bool isspace(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element do przetestowania.

Wartość zwracana

true jeśli testowany element jest znakiem odstępu; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype<CharType>:: spacja, Ch).

Przykład

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

using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result1 = isspace ( 'L', loc );
   bool result2 = isspace ( '\n', loc );
   bool result3 = isspace ( ' ', loc );

   if ( result1 )
      cout << "The character 'L' in the locale is "
           << "a whitespace character." << endl;
   else
      cout << "The character 'L' in the locale is "
           << " not a whitespace character." << endl;

   if ( result2 )
      cout << "The character 'backslash-n' in the locale is "
           << "a whitespace character." << endl;
   else
      cout << "The character 'backslash-n' in the locale is "
           << " not a whitespace character." << endl;

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

Isupper

Sprawdza, czy element w ustawieniach regionalnych ma wielkie litery.

template <class CharType>
bool isupper(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element do przetestowania.

Wartość zwracana

true jeśli testowany element jest wielkim znakiem; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype<CharType>:: upper, Ch).

Przykład

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

using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result1 = isupper ( 'L', loc );
   bool result2 = isupper ( 'n', loc );
   bool result3 = isupper ( '3', loc );

   if ( result1 )
      cout << "The character 'L' in the locale is "
           << "a uppercase character." << endl;
   else
      cout << "The character 'L' in the locale is "
           << " not a uppercase character." << endl;

   if ( result2 )
      cout << "The character 'n' in the locale is "
           << "a uppercase character." << endl;
   else
      cout << "The character 'n' in the locale is "
           << " not a uppercase character." << endl;

   if ( result3 )
      cout << "The character '3' in the locale is "
           << "a uppercase character." << endl;
   else
      cout << "The character '3' in the locale is "
           << " not a uppercase character." << endl;
}

isxdigit

Sprawdza, czy element w ustawieniach regionalnych jest znakiem używanym do reprezentowania liczby w postaci szesnastkowej.

template <class CharType>
bool isxdigit(CharType Ch, const locale& Loc)

Parametry

Ch
Element do przetestowania.

Loc
Ustawienia regionalne zawierające element do przetestowania.

Wartość zwracana

true jeśli testowany element jest znakiem używanym do reprezentowania liczby szesnastkowej; false jeśli tak nie jest.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc is( ctype CharType><:: xdigit, ). Ch

Cyfry szesnastkowe używają podstawy 16 do reprezentowania liczb, używając cyfr od 0 do 9 plus liter bez uwzględniania wielkości liter od A do F w celu reprezentowania liczb dziesiętnych od 0 do 15.

Przykład

// 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;
}

Tolower

Konwertuje znak do małej litery.

template <class CharType>
CharType tolower(CharType Ch, const locale& Loc)

Parametry

Ch
Znak, który ma zostać przekonwertowany na małe litery.

Loc
Ustawienia regionalne zawierające znak do przekonwertowania.

Wartość zwracana

Znak przekonwertowany na małe litery.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc tolower( Ch).

Przykład

// locale_tolower.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   char result1 = tolower ( 'H', loc );
   cout << "The lower case of 'H' in the locale is: "
        << result1 << "." << endl;
   char result2 = tolower ( 'h', loc );
   cout << "The lower case of 'h' in the locale is: "
        << result2 << "." << endl;
   char result3 = tolower ( '$', loc );
   cout << "The lower case of '$' in the locale is: "
        << result3 << "." << endl;
}

Toupper

Konwertuje znak do wielkiej litery.

template <class CharType>
CharType toupper(CharType Ch, const locale& Loc)

Parametry

Ch
Znak, który ma zostać przekonwertowany na wielkie litery.

Loc
Ustawienia regionalne zawierające znak do przekonwertowania.

Wartość zwracana

Znak przekonwertowany na wielkie litery.

Uwagi

Funkcja szablonu zwraca use_facet<ctype<CharType>>( ). Loc toupper( Ch).

Przykład

// locale_toupper.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   char result1 = toupper ( 'h', loc );
   cout << "The upper case of 'h' in the locale is: "
        << result1 << "." << endl;
   char result2 = toupper ( 'H', loc );
   cout << "The upper case of 'H' in the locale is: "
        << result2 << "." << endl;
   char result3 = toupper ( '$', loc );
   cout << "The upper case of '$' in the locale is: "
        << result3 << "." << endl;
}

Use_facet

Zwraca odwołanie do zestawu reguł określonego typu przechowywanego w ustawieniach regionalnych.

template <class Facet>
const Facet& use_facet(const locale& Loc);

Parametry

Loc
Ustawienia regionalne const zawierające typ przywoływanego aspektu.

Wartość zwracana

Odwołanie do aspektu klasy Facet zawartej w ustawieniach regionalnych argumentu.

Uwagi

Odwołanie do aspektu zwróconego przez funkcję szablonu pozostaje prawidłowe, o ile istnieje dowolna kopia zawierających ustawienia regionalne. Jeśli taki obiekt facet klasy Facet nie jest wymieniony w ustawieniach regionalnych argumentów, funkcja zgłasza bad_cast wyjątek.

Przykład

// locale_use_facet.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
using namespace std;

int main( )
{
   locale loc1 ( "German_Germany" ), loc2 ( "English_Australia" );
   bool result1 = use_facet<ctype<char> > ( loc1 ).is(
   ctype_base::alpha, 'a'
);
   bool result2 = use_facet<ctype<char> > ( loc2 ).is( ctype_base::alpha, '!'
   );

   if ( result1 )
      cout << "The character 'a' in locale loc1 is alphabetic."
           << endl;
   else
      cout << "The character 'a' in locale loc1 is not alphabetic."
           << endl;

   if ( result2 )
      cout << "The character '!' in locale loc2 is alphabetic."
           << endl;
   else
      cout << "The character '!' in locale loc2 is not alphabetic."
           << endl;
}
The character 'a' in locale loc1 is alphabetic.
The character '!' in locale loc2 is not alphabetic.

Zobacz też

<Ustawień regionalnych>