2013年12月4日星期三

File encoding conversion

Think about it in a directory of all files encoded into utf-8 how to achieve . No idea ! ! !
------ Solution ---------------------------------------- ----
use Notepad to open , save as utf8 format it ok
------ Solution ---------------------- ----------------------
or set the text file encoding
------ Solution in eclipse ----- ---------------------------------------
you can look in the JDK there is a OutputStreamWriter and InputStreamReader class, which is dedicated to two classes set encoding , you can file to write the correct encoding format , and then use OutputStreamWriter class converts to UTF-8 format, and then , all of the files are all in UTF-8 format .
If you do not understand , you can see what I wrote blog http://blog.csdn.net/dabing69221/article/details/17055503 I hope you can help !
------ Solution - -------------------------------------------
you recompile again try , Project -> clean .. or else you select the file and then change again
------ Solution -------------------- ------------------------
not on manually copied to the eclipse in it
------ Solution ----- ---------------------------------------
landlord can go to learn about coding theory . I understand that this problem could be like that.
landlord JAVA original file is not saved GBK format editing . Here that is saved .
set of encoding rules in eclipse , but the original document is set up in a way you read only the content you enter will be new to UTF8 encoding.
So, no matter how you operate, I think the error is always wrong. Here to explain .

1. written X coding rules file , save converted into 11,110,101 according to the data segment X rules.
2. opens the file , reads 11110101 data segment , according to the current encoding rules (UTF8), can not be interpreted , resulting in garbled.
3. resave the file as UTF8, garbled part is not modified, so the data segment or 11110101 . So it is not correct.

So please find the landlord file encoding conversion tool to convert from X encoded as UTF8, generate a new file. Remember, only 11,110,101 of this field is changed, it can make UTF8 correctly read and write. File content must be changed. Binary comparator can be used for comparison.





------ For reference only ---------------------------------- -----

early in the coding of the eclipse took it. But the import or distortion . Save the file as a single copy into utf-8 right. Very strange.
So I want the project to be imported using the program to start from the root of all manually turn into utf-8 a try. I do not know how to write programs .
import some items , when really disgusting coding problem ~ ~ ~ ~ ~ ~ ~
------ For reference only ----------------- ----------------------
I put the project file with Chinese in a java file as utf-8 's . ecilipse encoded as utf-8. Copy the two files to ecilipse , the original java file garbled. File utf-8 is no problem.
then ecilipse as the default encoding gbk. Copy the two files to ecilipse , the original java file garbled. File utf-8 is no problem.
is not to say that my ecilipse coding ineffective ! ! !

没有评论:

发表评论