Issue 2555: WideString asByteString does not return a ByteString

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 2555: WideString asByteString does not return a ByteString

Stéphane Ducasse
Reported by nils.winter, Today (2 hours ago)
WideString asByteString does not return a ByteString.

Pharo image: Pharo
Pharo core version: Pharo-1.1-11367-Beta
Virtual machine used: Squeak 4.2.4beta1U
Class browser used (if applicable): OBSystemBrowserAdaptor


Steps to reproduce:

1. 'π' asByteString isByteString "false, shouldn't that be true?"

Shouldn't that at least fail? I would suspect, that String>>asByteString should be something like

asByteString
        | string |
        "Convert the receiver into a ByteString"
        string := ByteString new: self byteSize.
        1 to: self byteSize do: [: i | string byteAt: i put: (self byteAt: i)].
        ^string

(copied that from asOctedString and replaced #size, #at:put: and #at: with their byte-versions
)

btw: The display of 'π' seems to be broken on 1.1 is displayed as '?? and has some strange cursor issued but functionality is there
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Issue 2555: WideString asByteString does not return a ByteString

Henrik Sperre Johansen

On Jun 15, 2010, at 12:09 09PM, Stéphane Ducasse wrote:

> Reported by nils.winter, Today (2 hours ago)
> WideString asByteString does not return a ByteString.
>
> Pharo image: Pharo
> Pharo core version: Pharo-1.1-11367-Beta
> Virtual machine used: Squeak 4.2.4beta1U
> Class browser used (if applicable): OBSystemBrowserAdaptor
>
>
> Steps to reproduce:
>
> 1. 'π' asByteString isByteString "false, shouldn't that be true?"
>
> Shouldn't that at least fail? I would suspect, that String>>asByteString should be something like
>
> asByteString
> | string |
> "Convert the receiver into a ByteString"
> string := ByteString new: self byteSize.
> 1 to: self byteSize do: [: i | string byteAt: i put: (self byteAt: i)].
> ^string
>
> (copied that from asOctedString and replaced #size, #at:put: and #at: with their byte-versions
> )
>
> btw: The display of 'π' seems to be broken on 1.1 is displayed as '?? and has some strange cursor issued but functionality is there
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Responded in detail in the issue.
Basically, asByteString is a bad name for what it does/should be allowed to do.
Zero senders, not sure if we should keep it for backwards-compat or just remove it (asOctetString is more descriptive with the same functionality as current).
Either way I added a slice with some better comments explaining its limitations.

Cheers,
Henry
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project