Is it possible to convert string or int to bytes? #436

Closed
opened 2023-02-08 22:10:09 +09:00 by davidyuk · 3 comments
davidyuk commented 2023-02-08 22:10:09 +09:00 (Migrated from gitlab.com)

https://docs.aeternity.com/aesophia/v7.0.1/sophia_stdlib/#bytes
I've found functions to convert bytes to int and string, but I can't find the reverse. Probably it is because int and string have dynamic size, but still. As a workaround, I've used strings to concatenate binary data.

https://docs.aeternity.com/aesophia/v7.0.1/sophia_stdlib/#bytes I've found functions to convert bytes to int and string, but I can't find the reverse. Probably it is because int and string have dynamic size, but still. As a workaround, I've used strings to concatenate binary data.
zxq9 commented 2023-03-30 17:08:51 +09:00 (Migrated from gitlab.com)

Created by: hanssv

No, it is not currently possible.

Originally strings used to be just "byte-arrays" but then it was important that they were interpreted as UTF8 (and thus not all byte-arrays are valid strings) - so we lost the generic byte arrays.

I'm curious if it would be possible to make compiler only changes that introduces arbitrary sized byte arrays. If time permits that might be something to look into.

*Created by: hanssv* No, it is not currently possible. Originally strings used to be just "byte-arrays" but then it was important that they were interpreted as UTF8 (and thus not all byte-arrays are valid strings) - so we lost the generic byte arrays. I'm curious if it would be possible to make compiler only changes that introduces arbitrary sized byte arrays. If time permits that might be something to look into.
zxq9 commented 2023-05-04 20:49:06 +09:00 (Migrated from gitlab.com)

Created by: hanssv

To follow up, it is only possible to do a little bit without changing FATE - I'll see if I can make a suggestion for Ceres instead...

*Created by: hanssv* To follow up, it is only possible to do a little bit without changing FATE - I'll see if I can make a suggestion for Ceres instead...
zxq9 commented 2023-06-13 15:46:44 +09:00 (Migrated from gitlab.com)

Created by: hanssv

See #456

*Created by: hanssv* See #456
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#436