您好,登錄后才能下訂單哦!
string 類型存儲字符串, 在solidity中使用了UTF-8格式來存儲字符串。
1 | string public name="jonson";//6a6f6e736f6e |
下面是錯誤的方式
1 | // function getLength() returns(uint){ |
1 | function getLength() public view returns(uint){ |
1 | function changeName() public{ |
1 | string public name2="我愛你"; |
1 | function getBytes() public view returns(bytes){ |
1 | pragma solidity ^0.4.23; |
1、字符串是特殊的動態(tài)長度字節(jié)數(shù)組
2、字符串不能夠字節(jié)的修改長度和內(nèi)容,需要轉(zhuǎn)換為bytes動態(tài)字節(jié)數(shù)組
3、字符串在solidity中使用了UTF8格式來存儲,所以漢字占了3個字節(jié),英文和特殊字符占了一個字節(jié)
本文鏈接: https://dreamerjonson.com/2018/11/15/solidity-11/
版權(quán)聲明: 本博客所有文章除特別聲明外,均采用 CC BY 4.0 CN協(xié)議 許可協(xié)議。轉(zhuǎn)載請注明出處!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。