java - How to correct change encoding of post query? -


when send post page without setcharacterencoding on server-side, фыв. setcharacterencoding(utf-8), ыва. how correct change character encoding of post query?

p.s.: read data servletinputstream.

code below.

dopost req.setcharacterencoding("utf-8"); bufferedreader r = new bufferedreader(new inputstreamreader(req.getinputstream())); string line; while ((line = r.readline()) != null) {     system.out.println(line); } 

bufferedreader r = new bufferedreader(     new inputstreamreader(req.getinputstream(), standardcharsets.utf_8)); 

with getinputstream have binary data without encoding. hence binary-to-text bridging class inputstreamreader needs correct encoding. otherwise uses system default system.getproperty("file.encoding").


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -

Why does a .NET 4.0 program produce a system.unauthorizedAccess error on a Windows Server 2012 machine with .NET 4.5 installed? -