How to store text longer than 32 bytes

AscarioQAscarioQ Member Posts: 3
I'm trying to store text longer than 32 bytes inside a struct which can hold other details about an item. What am I doing wrong?

I'm trying to save the following text: "This is a text using more than 32 bytes but fitting in 64bytes", unfortunately the approach below does not work correctly, it only saves the two first characters of the text.
contract text {
    struct textHolder {
        bytes32[2] text;
    }
    mapping (int => textHolder) textHolders;

    // adding "This is a text using more than 32 bytes but fitting in 64bytes"
    function addText(bytes32[2] text) returns (bool res){
        textHolders[0].text=text;
        return true;
    }

    // Returns only the first two letters in byte form: T and h. What do I do wrong?
    // Result: 0x54000000000000000000000000000000000000000000000000000000000000006800000000000000000000000000000000000000000000000000000000000000
    function getText() returns (bytes32[2] res){
        return textHolders[0].text;
    }
}
Sign In or Register to comment.