I don't want to start a philosophical discussion, but I'm puzzled: What 
constitutes "correct" behaviour in this case?

Are you saying that 'correct' would be something like:

1 printStringHex
 '0F'

and

1 hex 
 '16r01'
 
??



Em 20/12/2010 06:10, Stéphane Ducasse < [email protected] > escreveu:


On Dec 19, 2010, at 9:55 PM, Geoffroy Couprie wrote:

> Hello all,
> 
> I get a strange behaviour while trying to print hexadecimal values of a 
> string.
> 
> Context: I get a SHA1 hash from a binary stream, store it into a
> string, and I want to display that string (using asHex).
> 
> Problem: for values inferior to 16, the leading zero is ignored. (15
> -> 'F' instead of '0F').

indeed printStringHex prints F instead of 0F
15 printStringHex
 'F'
15 hex 
 '16rF'

Geoffroy could you add a variant that produces the correct behavior with some 
tests?

> I could modify SmallInteger>>printStringBase: to always include the
> leading zero, but I fear I'm going to break a lot of code doing that.
> Is there a better way to fix my problem? apart from using directly the
> following:
> aStream do:[:val | val printStringBase:16 nDigits:2]
> 
> Best regards,
> 
> Geoffroy
> 




Reply via email to