Enviado em 16/03/2015 - 13:34h
Pessoal, estou com uma dúvida. Se eu executo o comando:expr index "ab" b
expr index "áb" b
Enviado em 16/03/2015 - 16:11h
O awk reconhece locales diferentes de "C"/"POSIX". Minha configuração default de locale é LC_ALL=en_US.UTF-8. Eis alguns resultados.$ awk 'BEGIN { print index("ab", "b"); }' 2 $ awk 'BEGIN { print index("áb", "b"); }' 2 $ env LC_ALL=C awk 'BEGIN { print index("áb", "b"); }' 3
Enviado em 16/03/2015 - 14:16h
Enviado em 17/03/2015 - 10:05h
// index.c -- compile usando “gcc -std=c99 index.c -o index” #include <locale.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <wchar.h> #include <wctype.h> int main(int argc, char **argv){ wchar_t *haystack, *needle, *found; size_t haystack_len, needle_len; if(argc!=3){ fprintf(stderr, "usage: %s haystack needle\n", argv[0]); return 1; } // Usa variáveis de ambiente para definir locale. setlocale(LC_ALL, ""); haystack_len=strlen(argv[1]); needle_len=strlen(argv[2]); haystack=calloc(1+haystack_len, sizeof *haystack); needle=calloc(1+needle_len, sizeof *needle); mbsrtowcs(haystack, (const char **)&argv[1], haystack_len, NULL); mbsrtowcs(needle, (const char **)&argv[2], needle_len, NULL); found=wcsstr(haystack, needle)-haystack; printf("%zd\n", found? found-haystack: -1); return found==NULL; }
Enviado em 17/03/2015 - 10:14h
fdmarp,$expr index áb b 3 $ expr index ab b 2
$ expr --version expr (GNU coreutils) 8.22 Copyright (C) 2013 Free Software Foundation, Inc. Licença GPLv3+: GNU GPL versão 3 ou posterior <http://gnu.org/licenses/gpl.html> Este é um software livre: você é livre para alterá-lo e redistribuí-lo. NÃO HÁ GARANTIA, na máxima extensão permitida pela lei. Escrito por Mike Parker, James Youngman e Paul Eggert.
Enviado em 17/03/2015 - 11:08h
$ awk 'BEGIN { print index("ab", "b"); }' 2 $ awk 'BEGIN { print index("áb", "b"); }' 2 $ env LC_ALL=C awk 'BEGIN { print index("áb", "b"); }' 3
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Descritores de Arquivos e Swappiness
tux-gpt - Assistente de IA para o Terminal
Instalação e configuração do Chrony
Programa IRPF - Guia de Instalação e Resolução de alguns Problemas
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
O Que Fazer Após Instalar Ubuntu 25.04
O que você está ouvindo agora? [2] (175)
Copiar Layout do Teclado para aplicar em outra Distribuição (10)
Autenticação necessária. um aplicativo quer acesso ao chaveiro (2)