Solidity在函数里面返回中文报错原因

错误

from solidity: ParserError: Invalid character in string. If you are

trying to use Unicode characters, use a unicode"..." string literal.

--> contracts/text.sol:90:24: | 90 | return (1,true,"你好");


原因与解决方法

在Solidity中,如果你想在字符串中使用Unicode字符,需要使用Unicode字符串字面量。

例如\u后跟4位的Unicode编码。对于中文字符"你好",我们可以使用\u4F60\u597D来表示。

在线中文转换Unicode网站

给大家分享一个在线中文转换Unicode的网站
在线中文转换Unicode

相关推荐
Rockbean10 天前
10分钟智能合约:进阶实战-7.2 Foundry开发环境
web3·智能合约·solidity
Rockbean13 天前
10分钟智能合约:进阶实战-6.4 使合约拒绝服务
web3·智能合约·solidity
Rockbean13 天前
10分钟智能合约:进阶实战-6.3 重入攻击提取资金
web3·智能合约·solidity
木西14 天前
实战:基于 Solidity 0.8.27 与 OpenZeppelin V5 构建多链恶搞代币(以 SPX6900 为例)
web3·智能合约·solidity
m0_3801671416 天前
面向开发者的Top10加密货币数据API(2026年最新)
大数据·人工智能·区块链
2601_9594801516 天前
Moneta Markets亿汇:“比特币高位修复风险偏好”
区块链
m0_3801671416 天前
加密货币价格 API、市场数据 API 与 分析 API 有什么区别?
人工智能·ai·区块链
LedgerNinja16 天前
AEGET:提升决策效率,助力交易者建立清晰的交易体系
区块链
2601_9619633817 天前
Spring Boot集成电子签章的7个典型问题与解决方案:从入门到生产级实践
大数据·人工智能·spring boot·python·区块链·智能合约
zhuhai_xigedian17 天前
物联网技术在源网荷储系统中的创新应用
大数据·运维·人工智能·区块链·能源