The Michelson document from the Tezos Developers Resources page states the following about the string
type:
Strings, with some usual escape sequences: \n, \, ". Unescaped line-breaks (both \n and \r) cannot appear in a Michelson string. Moreover, the current version of Michelson restricts strings to be the printable subset of 7-bit ASCII, namely characters with codes from within [32, 126] range, plus the escaped characters mentioned above.
It sounds like that is not a good type to hold a UTF-8 value. It looks like there is another type bytes
. The documentation says the following.
Bytes are used for serializing data, in order to check signatures and compute hashes on them. They can also be used to incorporate data from the wild and untyped outside world.
This might be a good type to store UTF-8 value, but how do I use it?
For example, let's say I want to store a Russian phrase Привет, мир
in a Michelson contract that has an entrypoint store_message
with a parameter bytes
that updates the storage to that value. If I am using the tezos-client, what operations do I need to perform on that string before sending it to the entrypoint. Then when the storage is updated and I read the storage from the contract, what operation do I need to perform on bytes
to convert it back into the original message?