Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

287
Visualizações
Convert a spanish string to uppercase

I want to convert a Spanish string to uppercase. I use the function toupper for all characters. The function does not convert characters with accent:

PROTECCIóN

Nor the enye character:

DAñO

I use the setlocale function.

setlocale(LC_ALL, "es_ES");
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It is possible to get the good result with setlocale(LC_ALL, "es_ES.utf8");, and use of wchar_t and of towupper(.) function.

Output

protección daño  PROTECCIÓN DAÑO

#include <stdio.h>
#include <stdlib.h>
#include <wctype.h>
#include <wchar.h>
#include <locale.h>

int main(void) {
    if (!setlocale(LC_ALL, "es_ES.utf8")) return 1;
    wchar_t input[] = L"protección daño";
    int length = sizeof(input)/sizeof(input[0]);
    wchar_t output[length];
    for (int i = 0; i < length-1; ++i) {
        output[i] = towupper(input[i]);
    }
    output[length-1] = '\0';
    printf ("%ls  %ls\n", input, output);
    
    return 0;
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda