Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to determine Text File Encoding  RSS feed

 
sabbir kazi
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to determine the encoding format (whether UTF-8 or not) at the time of reading a text file using InputStream or whatever? I need to handle utf-8 encoded file differently from the normal text file.

Thanks in advance.
 
Manuel Palacio
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Current Java libraries or utilities don't do this by default. The way to do this is to look at the first bytes of the stream and try to guess. I have seen a couple of encoding detectors on the net but I haven't tried them.

http://cpdetector.sourceforge.net/index.shtml
[ April 10, 2006: Message edited by: Manuel Palacio ]
 
sabbir kazi
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manuel Palacio, for your reply.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!