错误
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

本文介绍了在Solidity编程中遇到的ParserError,原因是使用非Unicode字符串格式导致的。解决办法是使用u编码的Unicode字符串字面量,如u4F60u597D表示中文字符你好。同时推荐了一个在线工具帮助转换中文字符到Unicode编码。
8126

被折叠的 条评论
为什么被折叠?



