Also, the eclipse file encoding
When using eclipse to build web applications, Chinese Garbled text is always difficult to effectively solve. Below are some common solutions.
1. Change the project file encoding method
2. How to view the encoding method of a file?
3. How to modify the encoding method of a file?
1. How can I change the project file encoding method?
If the project is just getting started, we're lucky to get rid of the entire project's coding method: http://blog.csdn.net/xuqianghit/archive/2010/11/08/5995384.aspx.
2. How to view the encoding method of the file?
If a part of the project has been completed, but suddenly the two teams use different encoding methods, what should we do? First, the two sides of the ELE. Me encoding method are unified. The first question is: how to check the encoding method of the file? The simplest way is to use ie to view the file. First, use ie to open the file to be viewed and select the encoding method to view the file encoding.
3. How to modify the encoding method of a file?
Method 1: manually modify
Method 2: The program is automatically implemented, but the program needs to be manually written, or go online to down one. Well, start writing a simple program to convert characters.
Using
System;
Using
System. Text;
Namespace
ConvertExample
{
Class
ConvertExampleClass
{
Static
Void
Main ()
{
String
UnicodeString = "This string contains the unicode
Character Pi (\ u03a0 )"
;
// Create two different encodings.
Encoding ascii = Encoding. ASCII;
Encoding unicode =
Encoding. Unicode;
// Convert
The string into a byte [].
Byte
[] UnicodeBytes =
Unicode. GetBytes (unicodeString );
// Perform the conversion from one encoding to
Other.
Byte
[] AsciiBytes =
Encoding. Convert (unicode, ascii, unicodeBytes );
// Convert the new byte [] into a char [] and then
Into a string.
// This is
Slightly different approach to converting to revoke strate
// The use of GetCharCount/GetChars.
Char
[] AsciiChars = new
Char
[Ascii. GetCharCount (asciiBytes, 0,
AsciiBytes. Length)];
Ascii. GetChars (asciiBytes, 0,
AsciiBytes. Length, asciiChars, 0 );
String
AsciiString = new
String
(AsciiChars );
// Display the strings created before and after
Conversion.
Console. WriteLine ("Original string: {0 }"
,
UnicodeString );
Console. WriteLine ("Ascii converted string: {0 }"
,
AsciiString );
}
}
}