🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.c
Article #15314

Re: rot13 [Was : Re: conjugaison et autres ...]

#15314
From: Emmanuel Delahaye
Date: Sun, 02 Oct 2005 08:52
29 lines
2228 bytes
candide wrote on 02/10/05 :
> Effectivement, je me rends compte (google) qu'il n'y a pas que le codage 
> ascii. Ceci convient-il :
>
> if (s[i] >= 'a' && s[i] <= 'z')
> 			s[i] = 'a'+(s[i]-'a'+13)%26;
> if (s[i] >= 'A' && s[i] <= 'Z')
> 			s[i] = 'A'+(s[i]-'A'+13)%26;

Non, car il n'y a aucune garantie que les valeurs soient cons�cutives 
(� part pour 0-9, mais qui, � ma connaisance, n'est pas concern� par 
ROT-13)

Lid�e est de cr�er 2 tables avec tous les caract�res (A-Z) et (a-z), et 
de chercher dedans la position 'i' du caract�re avec strchr(). Ensuite, 
on va chercher le caract�re � (i + 13) % 26...

Pour chercher dans la bonne table, on utilise les filtres isprint(), 
isnum(), ispunct(), isupper() (<ctype.h>) etc. Jamais la valeur des 
caract�res.


-- 
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"There are 10 types of people in the world today;
those that understand binary, and those that dont."
Technical Details
Message-ID: <mn.128c7d5aa5238de0.15512@YOURBRAnoos.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!infeed-3.proxad.net!news18-e.free.fr!not-for-mail
References: <1126342327.583568.21420@g43g2000cwa.googlegroups.com> <4329e5d4$0$7846$8fcfb975@news.wanadoo.fr> <dge4b6$fqa$1@reader1.imaginet.fr> <432ab809$0$1734$8fcfb975@news.wanadoo.fr> <mn.84b07d59016a857b.31483@laposte.net> <433f16ac$0$27406$8fcfb975@news.wanadoo.fr> <mn.10907d5a55119e84.15512@YOURBRAnoos.fr> <433f9cb1$0$7821$8fcfb975@news.wanadoo.fr>

Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,b21b26167a936e28
X-Google-Attributes: gidf9822,public
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!infeed-3.proxad.net!news18-e.free.fr!not-for-mail
Subject: Re: rot13 [Was : Re: conjugaison et autres ...]
From: "Emmanuel Delahaye" <emdel@YOURBRAnoos.fr>
References: <1126342327.583568.21420@g43g2000cwa.googlegroups.com> <4329e5d4$0$7846$8fcfb975@news.wanadoo.fr> <dge4b6$fqa$1@reader1.imaginet.fr> <432ab809$0$1734$8fcfb975@news.wanadoo.fr> <mn.84b07d59016a857b.31483@laposte.net> <433f16ac$0$27406$8fcfb975@news.wanadoo.fr> <mn.10907d5a55119e84.15512@YOURBRAnoos.fr> <433f9cb1$0$7821$8fcfb975@news.wanadoo.fr>
Newsgroups: fr.comp.lang.c
Message-ID: <mn.128c7d5aa5238de0.15512@YOURBRAnoos.fr>
X-Newsreader: MesNews/1.04.00.00-fr
Date: Sun, 02 Oct 2005 10:52:36 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 31
Organization: Guest of ProXad - France
NNTP-Posting-Date: 02 Oct 2005 10:52:37 MEST
NNTP-Posting-Host: 81.65.109.78
X-Trace: 1128243157 news18-e.free.fr 4342 81.65.109.78:17299
X-Complaints-To: abuse@proxad.net