Java: Convert String “\uFFFF” into char

前端 未结 4 2056
眼角桃花
眼角桃花 2020-12-03 03:07

Is there a standard method to convert a string like \"\\uFFFF\" into character meaning that the string of six character contains a presentation of one unicode character?

4条回答
  •  广开言路
    2020-12-03 03:29

    If you are parsing input with Java style escaped characters you might want to have a look at StringEscapeUtils.unescapeJava. It handles Unicode escapes as well as newlines, tabs etc.

    String s = StringEscapeUtils.unescapeJava("\\u20ac\\n"); // s contains the euro symbol followed by newline
    

提交回复
热议问题