Hilaire,

You should use a character encoder, for example like this:

| packet |
packet := ByteArray streamContents: [:str |
        str nextPut: 16r02;                     "TOSERVER_INIT"
                nextPut: 28;                                    
"SER_FMT_VER_HIGHEST_READ"
                uint16: 0;                                      
"NETPROTO_COMPRESSION_NONE"
                uint16: 37;                                     
"CLIENT_PROTOCOL_VERSION_MIN"
                uint16: 38;                                     
"LATEST_PROTOCOL_VERSION"
                nextPutAll: ('Player' encodeWith: #utf8).               "Player 
name"
].
packet contents.

Note that there are different options:

'Player' encodeWith: #utf8.
'Player' encodeWith: #null.
'Player' encodeWith: #ascii.

But for an ASCII string they give the same result.

#null asZnCharacterEncoder.
#ascii asZnCharacterEncoder.

There is also #utf8Encoded on String.

Sven

> On 16 Jan 2020, at 11:54, HilaireFernandes <[email protected]> wrote:
> 
> | packet |
> packet := ByteArray streamContents: [:str |
>       str nextPut: 16r02;                     "TOSERVER_INIT"
>               nextPut: 28;                                    
> "SER_FMT_VER_HIGHEST_READ"
>               uint16: 0;                                      
> "NETPROTO_COMPRESSION_NONE"
>               uint16: 37;                                     
> "CLIENT_PROTOCOL_VERSION_MIN"
>               uint16: 38;                                     
> "LATEST_PROTOCOL_VERSION"
>               nextPutAll: 'Player'.           "Player name"
> ].
> packet contents


Reply via email to