PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > sprintf percent sign problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
sprintf percent sign problem

Réponse
 
LinkBack Outils de la discussion
Vieux 04/11/2007, 08h41   #1
mpthimios@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut sprintf percent sign problem

Hi,
I am trying to format some text using sprintf. The text itself
contains the percent sign (%).

When I use it without any escape character, as expected ruby throws
error (unkonown format sequence).

When I use the "\%" sequence ruby complaints when the "\%" is
somewhere in the text. When it is at the end it works but I don't want
it there.

When I use the "%%" sequence, I get the exact sequence as output ("%%"
is printed!!).. \

Has anyone observed this behavior? Am I doing something wrong or it is
a ruby bug?

Thanks in advance,
Efthimios.


  Réponse avec citation
Vieux 04/11/2007, 09h09   #2
bbxx789_05ss@yahoo.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sprintf percent sign problem

Duplicate post. See here:

http://www.ruby-forum.com/topic/130350#new
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 04/11/2007, 12h30   #3
alex@blackkettle.org
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sprintf percent sign problem

mpthimios wrote:
> Hi,
> I am trying to format some text using sprintf. The text itself
> contains the percent sign (%).
>
> When I use it without any escape character, as expected ruby throws
> error (unkonown format sequence).
>
> When I use the "\%" sequence ruby complaints when the "\%" is
> somewhere in the text. When it is at the end it works but I don't want
> it there.
>
> When I use the "%%" sequence, I get the exact sequence as output ("%%"
> is printed!!).. \
>
> Has anyone observed this behavior? Am I doing something wrong or it is
> a ruby bug?


I don't see that:

irb(main):001:0> text = "foo%%bar"
=> "foo%%bar"
irb(main):002:0> sprintf(text)
=> "foo%bar"

--
Alex

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h52.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13285 seconds with 11 queries