简体   繁体   中英

Encode french character in Java?

How can i encode french Character?

let's say i have String strMEssage='Pour se désinscrire du service ';
String utf8 = new String(strMessage.getBytes("ISO8859_15"),"ISO8859_15"); 

o/P is not proper for special char ? is coming

You seem to be mixing a lot of concepts here.

A String is a sequence of char s. The fact that internally Java uses UTF-16 is irrelevant.

You never send Java String s as is, nor receive a Java String , nor write String s directly in a file, not read String s directly from a file. You send/receive bytes . And turning bytes into characters and the reverse is made by a Charset{Decoder,Encoder} .

In Java source files, just write the string as you want it. When you send/write/receive/read it, use the correct encoding. That is all there is to it.

See Charset for generic information.

And if you use a Reader or Writer , always specify the encoding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM