mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9412 from ethereum/unicode-string
[BREAKING] Support unicode string literal type
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
contract C {
|
||||
string s = "\xf0\x9f\xa6\x84";
|
||||
}
|
||||
// ----
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
contract test {
|
||||
function f() public pure returns (string memory) {
|
||||
return "hello world";
|
||||
}
|
||||
function g() public pure returns (string memory) {
|
||||
return unicode"hello world";
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,7 @@
|
||||
contract test {
|
||||
function f() public pure returns (bytes32) {
|
||||
bytes32 escapeCharacters = unicode"foo" unicode"😃, 😭, and 😈" unicode"!";
|
||||
return escapeCharacters;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,8 @@
|
||||
contract test {
|
||||
function f() public pure returns (bytes32) {
|
||||
bytes32 escapeCharacters = "foo" hex"aa" unicode"😃, 😭, and 😈" "!" hex"00";
|
||||
return escapeCharacters;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (106-113): Expected ';' but got 'HexStringLiteral'
|
||||
@@ -1,6 +1,6 @@
|
||||
contract test {
|
||||
function f() public pure returns (string memory) {
|
||||
return "😃, 😭, and 😈";
|
||||
return unicode"😃, 😭, and 😈";
|
||||
}
|
||||
}
|
||||
// ----
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
contract test {
|
||||
function f() public pure returns (string memory) {
|
||||
return "😃, 😭, and 😈";
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError 8936: (86-88): Invalid character in string.
|
||||
@@ -19,3 +19,4 @@ contract test {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
|
||||
Reference in New Issue
Block a user