0

I am trying to concatenate byte and uint in my project. I am using the following logic I found somewhere:

bytes data = abi.encodePacked("Gold_",Gold);

where Gold contains a uint8 number. The output of above line is: Gold_\u0004, where it should be: Gold_4

Anyone please tell me what is the issue? or Any other method that I should use to concatenate the string and uint8?

1 Answers1

1

Don't know what you're trying to do (probably a better way than all this concatenation in solidity), but I'd probably convert the uint to a string and then concatenate the strings:

Uint to string methods: https://stackoverflow.com/questions/47129173/how-to-convert-uint-to-string-in-solidity

concat strings: How to concatenate strings in solidity?

thefett
  • 3,873
  • 5
  • 26
  • 48