5

I'm making a pallet that takes a string as the input. I tested it and it works well with English words, but when I try Vietnamese, the input box turned red and I couldn't submit the extrinsic. How can I solve this? In my code, the data type I used to save the text is Vec<u8>

Ienter image description here

3
  • 1
    Did you try to use Bytes there? ie Viêt -> 0x5669c3aa74? Feb 14, 2022 at 8:52
  • @ArturGontijo No (?), I don't quite understand what you mean. Can you explain further? I'd be very appreciative.
    – Minh Mốc
    Feb 14, 2022 at 9:04
  • 1
    Posted it as an answer, let me know if I was clear there =). Feb 14, 2022 at 11:23

1 Answer 1

6

You can use hex decimals (0x...) there too.

As you can see in its placeholder, when the Bytes field is empty: enter image description here

So you will need a tool to convert your UTF8 string into bytes, like:

fn main() {
    println!("0x{}", hex::encode("Viêt"));
}
// Outputs: 0x5669c3aa74

Now you can fill the field with 0x5669c3aa74 and submit the extrinsic.

3
  • Thank you alot!
    – Minh Mốc
    Feb 14, 2022 at 14:18
  • This would also work with emojis, right?
    – stano
    Feb 17, 2022 at 9:20
  • Yep, you can send a 👍 as 0xf09f918d. Feb 17, 2022 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.