Also, the eclipse file encoding

Source: Internet
Author: User

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 );
}
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.