In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use Java to convert strings between ISO-8859-1 and UTF-8", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to use Java to convert strings between ISO-8859-1 and UTF-8"!
We all know that in some special scenarios, we need to use a special encoding format, such as UTF-8, but the default encoding of the system is ISO-8859-1.
Then we need to convert the code to the coding format we need.
This is the problem I encountered today. I need to perform two encoding conversions on the string, so how do I do the related conversion?
Below, the author describes the use of Java code to convert strings between ISO-8859-1 and UTF-8, as follows:
The idea of realization is:
Use
GetBytes ("UTF-8")
Or
GetBytes ("ISO-8859-1")
A byte array that can be converted to a specified character encoding
The conversion between them is based on a string as a bridge.
Example:
Sharing examples of conversion between ISO-8859-1 and UTF-8
Package com.java265.other;public class Test {/ * * java265.com examples of conversion between encoding types are shared * * / public static void main (String [] args) throws Exception {String str = "java265.com"; byte [] latin1 = str.getBytes ("ISO-8859-1"); byte [] utf8 = new String (latin1, "ISO-8859-1"). GetBytes ("UTF-8") Latin1 = new String (utf8, "UTF-8") .getBytes ("ISO-8859-1") }} Thank you for your reading, the above is the content of "how to use Java to convert strings between ISO-8859-1 and UTF-8". After the study of this article, I believe you have a deeper understanding of how to use Java to convert strings between ISO-8859-1 and UTF-8. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.