encoding - Can't convert UTF-8 from Scanner to Console(System.out) with original result in Java -
i know java 8 uses utf-8 standard encoding. when read string standard-input(system.in) scanner using "utf-8" try print console , string not in right origin show beneath ,but initialized string console show right original string without unexpected result.how can fix this?please me!
use scanner not string constructor encode input.i know how convert input utf-8 wrong happened result , asked reason , solution solve problem ,not asking way encode string utf-8.
here code:
import java.nio.charset.charset; import java.util.scanner; public class charset { public static void main(string[] args) { system.out.println(charset.defaultcharset()); scanner sc =new scanner(system.in,"utf-8"); system.out.println(sc.nextline()); system.out.println("á ă ấ"); } } -here output:
run: utf-8 á ă ấ � ? ? á ă ấ build successful (total time: 10 seconds)
try 1 set utf8 eclipse if not helping try read file instead of console see happens.
Comments
Post a Comment