Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in using the UTF-8 !!!!!!!! Plz help me out

Maneesh_3
Occasional Contributor

Problem in using the UTF-8 !!!!!!!! Plz help me out

hi to All,
I am facing a problem in the java program . The problem is thats
1) I have a text file which i saved in UTF-8 encoding containing only the ASCII characters
2)When i am reading the file using the Reader class ave the UTF-8 encoding
3) When i am reading the line this text file , i am getting one extra character in the beginning of the everyline
I am not able to understand from where this extra characters comes

But when i make a file text using the Writer class having the encoding UTF-8 then there is no extra character
3 REPLIES
florence mathon lermusi
Trusted Contributor

Re: Problem in using the UTF-8 !!!!!!!! Plz help me out

try to look at the iconv command to change the encoding format/character set of your file
Brian Crabtree
Honored Contributor

Re: Problem in using the UTF-8 !!!!!!!! Plz help me out

You are most likely seeing a carriage return in the file.

Brian
Muthukumar_5
Honored Contributor

Re: Problem in using the UTF-8 !!!!!!!! Plz help me out

hai,

Your text file format is containing one more ascii character. We can identify that by,

cat | head -2 | od -bc

You will see encodings of ascii characters,text file will contain ASCII 13 character on unix. You have to change it with dos2ux input-file. It will change that file with that ascii character.

Example:>
cat hai.text | od -bc
0000000 164 145 163 164 015 012 150 141 151 015 012 150 145 154 154 157
t e s t \r \n h a i \r \n h e l l o
0000020

dos2unix hai.text

After change,
0000000 164 145 163 164 012 150 141 151 012 150 145 154 154 157
t e s t \n h a i \n h e l l o
0000016


see dos2unix man page to know more.
Easy to suggest when don't know about the problem!