By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,630 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,630 IT Pros & Developers. It's quick & easy.

how to find encoding of a file in linux?

P: 1
hello,

i would like to know how to write a code in python to find the encoding of a file in linux.

i require it urgently. please help! thanx in advance.
Jan 9 '07 #1
Share this Question
Share on Google+
1 Reply


bartonc
Expert 5K+
P: 6,596
hello,

i would like to know how to write a code in python to find the encoding of a file in linux.

i require it urgently. please help! thanx in advance.
>>> test = open("test", "w")
>>> print test.encoding
None
>>> test.close()
>>>

encoding
The encoding that this file uses. When Unicode strings are written to a file, they will be converted to byte strings using this encoding. In addition, when the file is connected to a terminal, the attribute gives the encoding that the terminal is likely to use (that information might be incorrect if the user has misconfigured the terminal). The attribute is read-only and may not be present on all file-like objects. It may also be None, in which case the file uses the system default encoding for converting Unicode strings.
New in version 2.3.
Jan 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.