Skip to content

Solidity: If a dev passes a unicode string as token name, unicode"..." string literal should be used #475

@0xNeshi

Description

@0xNeshi

Currently passing Unicode strings as token names is supported in Wizard, but it produces invalid Solidity code.

For example, if we open Wizard Solidity and in the "Name" field we type MyTokeć, this will be the output:

// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.22;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";

contract MyTokec is ERC20, ERC20Permit {
    constructor() ERC20("MyTokeć", "MTK") ERC20Permit("MyTokeć") {}
}

But this is not valid Solidity code as string literals must be ASCII characters, so the compiler will throw an error. To make this compile, the string literal must be prepended with the unicode keyword:

contract MyTokec is ERC20, ERC20Permit {
    constructor() ERC20(unicode"MyTokeć", "MTK") ERC20Permit(unicode"MyTokeć") {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions