This section explains how to handle non-English string (multibyte characters) in Solidity.
Syntax
To handle non-English string in Solidity, prefix the string with the unicode prefix.
unicode"string"
Sample Code
It is easier to understand if you see the actual code, so a sample code is shown below.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Test {
// Assign Japanese string to the variable
string greeting = unicode"こんにちは😃";
function sayHello() public view returns(string memory) {
return greeting;
}
}
When dealing with non-English string (multibyte characters) such as Japanese, you can simply add a unicode prefix.