Arbitrary length strings?

ThePiachuThePiachu Member Posts: 16
edited June 2015 in Solidity
I am currently trying to write a contract that will be storing some simple messages. I didn't want the message length to be limited, so I figured I would put it as:
contract Contract{
	struct owner {
		address ownerAddress;
		string message;
However, I got an error of "Error: Unable to convert elementary typename string to type." while typing this in Mix. If I replace "string" with "string32", the contract appears to compile just fine. Is there some way around this limit on strings if I want to store longer messages than 32 characters?
Post edited by StephanTual on


  • chrisethchriseth Member Posts: 170 ✭✭✭
    Latest develop has "bytes", "bytes1" to "bytes32" and "string", while the latter was only re-introduced this week. The difference between "bytes" and "string" is that strings are assumed to be utf-8 encoded while "bytes" is binary data. You cannot yet access individual characters in (or determine the length of) a string, as this would require to traverse the whole string up to that point and interpret the utf-8 code points.
  • brandonzfrbrandonzfr Member Posts: 20
    @ThePiachu did you find a good solution?
Sign In or Register to comment.