Unicode to string conversion in Java

后端 未结 4 1506
孤街浪徒
孤街浪徒 2021-01-03 03:13

I am building a language, a toy language. The syntax \\#0061 is supposed to convert the given Unicode to an character:

String temp = yytext().su         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-03 03:37

    i am basically trying to convert unicode to a character by supplying only '0061' to a method, help.

    char fromUnicode(String codePoint) {
      return (char)  Integer.parseInt(codePoint, 16);
    }
    

    You need to handle bad inputs and such, but that will work otherwise.

提交回复
热议问题