Suggestion:The encode conversion
See original GitHub issueSir,I think over this question in django
UnicodeDecodeError at /admin/core/book/import/
'utf8' codec can't decode byte 0xc4 in position 0: invalid continuation byte
then I use vim set fileencoding
,I found the csv standard of file exported from the django-import-export
is UTF-8
,I search it on internet,I also found that if i use utf-8
standard file to import,it’s OK.
Maybe I use the OS in Chinese language so it cause the problem.Would you please modify the project:If the encode of import-file
or export-file
is not utf-8
,first convert it to utf-8
,then process other code?
I have write some code to fix the encode convertion:
import chardet
def convertEncoding(from_encode,to_encode,old_filepath,target_file):
f1=file(old_filepath)
content2=[]
while True:
line=f1.readline()
content2.append(line.decode(from_encode).encode(to_encode))
if len(line) ==0:
break
f1.close()
f2=file(target_file,'w')
f2.writelines(content2)
f2.close()
convertFile = open('1234.csv','r')
data = convertFile.read()
convertFile.close()
convertEncoding(chardet.detect(data)['encoding'], "utf-8", "1234.csv", "1234_bak.csv")
I am a newbie , my code is not concise.would you please think about that and integrite the regular to the project?I very like this project,thanks for your reputation!
Issue Analytics
- State:
- Created 10 years ago
- Comments:23 (9 by maintainers)
Top Results From Across the Web
Character encoding conversion - EMVLab
From text. From hex (ASCII) From hex (EBCDIC), To text. To hex (ASCII) To hex (EBCDIC), With spaces. No spaces. C literal ...
Read more >UndefinedConversionError: U+03B1 from UTF-8 to ISO-8859 ...
Method fails due to Encoding::UndefinedConversionError: U+03B1 from UTF-8 to ISO-8859-1 · Ask Question. Asked 9 years, 5 months ago. Modified 9 ...
Read more >Character encoding and locales - Philip Withnall
The problem with the first is that iconv will stop converting when it encounters something it can't convert. The problem with the second...
Read more >An Introduction to Arithmetic Coding
Arithmetic coding is a data compression technique that encodes data (the data string) by ... values of higher-order bits until a 0 is...
Read more >Version History: ConvertXtoHD - VSO Software
[Bug] conversion stops at around 90% during menu encoding ... [Suggestion] The thumbnail frames should have all sides of equal thickness.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Me too
Can’t get it parsed with utf-8 in deploy environment, although in development works fine
Hi guys, Any updates on this, currently experiencing similar issues.