Nota
O acesso a esta página requer autorização. Podes tentar iniciar sessão ou mudar de diretório.
O acesso a esta página requer autorização. Podes tentar mudar de diretório.
O <locale> cabeçalho fornece as seguintes funções:
has_facet
Testa se uma faceta específica é armazenada em uma localidade especificada.
template <class Facet>
bool has_facet(const locale& Loc);
Parâmetros
Loc
O local a ser testado para a presença de uma faceta.
Valor de retorno
true se o local tem a faceta testada; false se não o fizer.
Observações
A função de modelo é útil para verificar se facetas não obrigatórias estão listadas em uma localidade antes use_facet de ser chamada para evitar a exceção que seria lançada se ela não estivesse presente.
Exemplo
// 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
Testa se um elemento em uma localidade é um caractere alfabético ou numérico.
template <class CharType>
bool isalnum(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento alfanumérico a ser testado.
Loc
A localidade que contém o elemento alfanumérico a ser testado.
Valor de retorno
true se o elemento ensaiado for alfanumérico; false se não for.
Exemplo
// 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
Testa se um elemento em uma localidade é um caractere alfabético.
template <class CharType>
bool isalpha(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento alfabético a ser testado.
Valor de retorno
true se o elemento testado for alfabético; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: alfa, Ch).
Exemplo
// 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
Testa se um elemento em uma localidade é um caractere de controle.
template <class CharType>
bool iscntrl(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento a ser testado.
Valor de retorno
true se o elemento testado for um carácter de controlo; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: cntrl, Ch).
Exemplo
// 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
Testa se um elemento em uma localidade é um caractere numérico.
template <class CharType>
bool isdigit(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento a ser testado.
Valor de retorno
true se o elemento testado for um caractere numérico; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: dígito, Ch).
Exemplo
// 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
Testa se um elemento em uma localidade é um caractere alfanumérico ou de pontuação.
template <class CharType>
bool isgraph(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento a ser testado.
Valor de retorno
true se o elemento testado for um caractere alfanumérico ou de pontuação; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: gráfico, Ch).
Exemplo
// 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;
}
é mais lento
Testa se um elemento em uma localidade é minúsculo.
template <class CharType>
bool islower(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento a ser testado.
Valor de retorno
true se o elemento testado for um caractere minúsculo; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: inferior, Ch).
Exemplo
// 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
Testa se um elemento em uma localidade é um caractere imprimível.
template <class CharType>
bool isprint(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento a ser testado.
Valor de retorno
true se o elemento testado for imprimível; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: impressão, Ch).
Exemplo
// 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
Testa se um elemento em uma localidade é um caractere de pontuação.
template <class CharType>
bool ispunct(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento a ser testado.
Valor de retorno
true se o elemento testado for um caractere de pontuação; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: punct, Ch).
Exemplo
// 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;
}
ISSspace
Testa se um elemento em uma localidade é um caractere de espaço em branco.
template <class CharType>
bool isspace(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento a ser testado.
Valor de retorno
true se o elemento testado for um caractere de espaço em branco; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: espaço, Ch).
Exemplo
// 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;
}
Ceia
Testa se um elemento em uma localidade está em maiúsculas.
template <class CharType>
bool isupper(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento a ser testado.
Valor de retorno
true se o elemento testado for um caractere maiúsculo; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: superior, Ch).
Exemplo
// 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
Testa se um elemento em uma localidade é um caractere usado para representar um número hexadecimal.
template <class CharType>
bool isxdigit(CharType Ch, const locale& Loc)
Parâmetros
Ch
O elemento a ser testado.
Loc
A localidade que contém o elemento a ser testado.
Valor de retorno
true se o elemento testado for um caractere usado para representar um número hexadecimal; false se não for.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
is( ctype<CharType>:: xdigit, Ch).
Os dígitos hexadecimais usam a base 16 para representar números, usando os números de 0 a 9 mais as letras de A a F que não diferenciam maiúsculas de minúsculas para representar os números decimais de 0 a 15.
Exemplo
// 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;
}
abaixar
Converte um caractere em minúsculas.
template <class CharType>
CharType tolower(CharType Ch, const locale& Loc)
Parâmetros
Ch
O caractere a ser convertido em minúsculas.
Loc
A localidade que contém o caractere a ser convertido.
Valor de retorno
O caractere convertido em minúsculas.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
abaixar(Ch).
Exemplo
// 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;
}
Tosuperior
Converte um caractere em maiúsculas.
template <class CharType>
CharType toupper(CharType Ch, const locale& Loc)
Parâmetros
Ch
O caractere a ser convertido em maiúsculas.
Loc
A localidade que contém o caractere a ser convertido.
Valor de retorno
O caractere convertido em maiúsculas.
Observações
A função de modelo retorna use_facet<ctype<CharType>>(Loc).
toupper(Ch).
Exemplo
// 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
Retorna uma referência a uma faceta de um tipo especificado armazenada em uma localidade.
template <class Facet>
const Facet& use_facet(const locale& Loc);
Parâmetros
Loc
A localidade const que contém o tipo de faceta que está sendo referenciada.
Valor de retorno
Uma referência à faceta da classe Facet contida na localidade do argumento.
Observações
A referência à faceta retornada pela função de modelo permanece válida enquanto existir qualquer cópia da localidade que contém. Se nenhum desses objetos de faceta da classe Facet estiver listado na localidade do argumento, a função lançará uma bad_cast exceção.
Exemplo
// 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.