Display special characters using System.out.println

前端 未结 4 490
不知归路
不知归路 2020-11-29 08:23

I\'m having trouble sending or displaying text with special characters from my webservice to my database. On my eclipse I have set the character encoding to UTF-8 but it sti

4条回答
  •  情深已故
    2020-11-29 09:02

    See if this works.

        PrintStream out = new PrintStream(System.out, true, "UTF-8");
        out.println(test);
    

    For storing in DB, use following to explicitly encode the string in UTF-8

    String newString = new String(test.getBytes(), "UTF8");
    

提交回复
热议问题