开发者

ASCII to UTF-8 conversion in java

开发者 https://www.devze.com 2023-03-05 00:06 出处:网络
i have a problem which i uploaded data using .CSV f开发者_运维知识库ile format and it read by java class.and i would be store in db.upto now no problem,but when i read the data from db then data conta

i have a problem which i uploaded data using .CSV f开发者_运维知识库ile format and it read by java class.and i would be store in db.upto now no problem,but when i read the data from db then data contains some special characters.

so please could you help me here

Thanks in advance.


ASCII-7 is compatible with UTF-8. There is nothing you need to do turn turn ASCII-7 into UTF-8 (but it doesn't work the other way)


This is an article you should really read.

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Next, to answer your question:

  • To Read a file encoded with UTF-8, use a BufferedReader:

    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
    
  • To Write a file encoded with UTF-8 use a BufferedWriter:

    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
    

Make sure that the transmittion of the data through the sockets goes correct.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号