'To many characters in character literal (surrogate characters) [duplicate]

I'm facing this error

To many caracters in character literal.

I know a similar question was already answered. Plz help me with this because that answer does not work for me.

Here is my code

case 1:

        for (int charOne = 0; charOne <= strBld.length() - 1; charOne++) {
                char a = strBld.charAt(charOne);
                char newCh = getCharOne(a);
                strBld.setCharAt(charOne, newCh);
        }

        break;

This is working fine.


    private char getCharOne(char a){
        char ch = a;
    
        if (ch == 'B' || ch == 'b') {
            ch = '๒';
        }

        return ch;

    }

But now I want to use this (surrogate characters)

🅐

when i paste it converts into \uD83C\uDD50 this format and an error shown To many characters in character literal


    private char getCharOne(char a){
        char ch = a;
        if (ch == 'A' || ch == 'a') {
            ch = '\uD83C\uDD50';
        }

        return ch;
    }



Solution 1:[1]

You can't write more than one character in ' '. You have defined ch as character so you can't give string to it You should define another variable as string and give \uD83C\uDD50 to it. for example:

var a:String
a="\uD83C\uDD50"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MMG