02-23-2009, 11:02 PM | #1 |
Member
Posts: 20
Karma: 10
Join Date: Nov 2007
Device: PRS-505
|
how to add encoding?
When I start rtf2lrf with
rtf2lrf (calibre 0.4.130) rtf2lrf --encoding=cp-1251 --keep-intermediate-files z.rtf It says Converting XML to HTML... Traceback (most recent call last): File "c:\Program Files\calibre\library.zip\calibre\customize\ui.py" , line 127, in get_file_type_metadata File "calibre\customize\builtins.pyo", line 68, in get_metadata File "c:\Program Files\calibre\library.zip\calibre\ebooks\lrf\meta. py", line 2 23, in get_metadata File "c:\Program Files\calibre\library.zip\calibre\ebooks\lrf\meta. py", line 4 42, in __init__ LRFException: D:\lib\!ebook\z\z.rtf has an invalid LRF header. Are you sure it i s an LRF file? Processing u'index.html' Traceback (most recent call last): File "convert_from.py", line 189, in <module> File "convert_from.py", line 85, in main File "convert_from.py", line 69, in process_file File "c:\Program Files\calibre\library.zip\calibre\ebooks\lrf\html\ convert_fro m.py", line 1922, in process_file File "c:\Program Files\calibre\library.zip\calibre\ebooks\lrf\html\ convert_fro m.py", line 277, in __init__ File "c:\Program Files\calibre\library.zip\calibre\ebooks\lrf\html\ convert_fro m.py", line 385, in add_file LookupError: unknown encoding: cp-1251 What's missing for cp-1251 encoding and where I can get it? What file is it looking for and can I create it myself (assuming I know the relation between cp-1251 codepoints and unicode, but do not know python)? Thank you. |
02-24-2009, 12:40 AM | #2 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Does the file library.zip in the calibre install folder contain the file encodings\cp1251.py?
|
Advert | |
|
02-24-2009, 07:18 AM | #3 |
Member
Posts: 20
Karma: 10
Join Date: Nov 2007
Device: PRS-505
|
It has cp1251.pyo file.
(But I do not see cp1251.py) |
02-24-2009, 01:36 PM | #4 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
hmm the pyo file is all that should be required.
what does the following command in a terminal give you? [code] calibre-debug -c "print 'abc'.decode('cp1251')" |
02-25-2009, 09:18 PM | #5 |
Member
Posts: 20
Karma: 10
Join Date: Nov 2007
Device: PRS-505
|
D:\>calibre-debug -c "print 'abc'.decode('cp1251')"
abc BTW, I might have misspelled cp1251. The following line gives error rtf2lrf --encoding=cp-1251 --keep-intermediate-files z.rtf But this line does not, but still does not produce readable result. D:\>rtf2lrf --encoding=cp1251 z.rtf Converting RTF to XML... Parsing XML... Converting XML to HTML... Traceback (most recent call last): File "c:\Program Files\calibre\library.zip\calibre\customize\ui.py" , line 127, in get_file_type_metadata File "calibre\customize\builtins.pyo", line 68, in get_metadata File "c:\Program Files\calibre\library.zip\calibre\ebooks\lrf\meta. py", line 223, in get_metadata File "c:\Program Files\calibre\library.zip\calibre\ebooks\lrf\meta. py", line 442, in __init__ LRFException: D:\z.rtf has an invalid LRF header. Are you sure it is an LRF file? Processing u'index.html' Parsing HTML... Converting to BBeB... Rationalizing font sizes... Output written to D:\z.lrf z.rtf is a simple rtf file. It consists of 2 lines of Russian alphabet. It is viewable by both WordPad and WordViewer (not sure about MSWord, do not have one). It is really small, I will post it here: {\rtf1\ansi\ansicpg1251\deff0\deflang1049\deflangf e1049\deftab708{\fonttbl{\f0\fswiss\fprq2\fcharset 204{\*\fname Arial CYR;}Arial;}{\f1\froman\fprq2\fcharset204{\*\fname Times New Roman CYR;}Times New Roman;}{\f2\fmodern\fprq1\fcharset204{\*\fname Courier New CYR;}Courier New;}} \viewkind4\uc1\pard\f0\fs20\par \lang1049\f1\'c0\'c1\'c2\'c3\'c4\'c5\'c6\'c7\'c8\' c9\'ca\'cb\'cc\'cd\'ce\'cf\'d0\'d1\'d2\'d3\'d4\'d5 \'d6\'d7\'d8\'d9\'da\'db\'dc\'dd\'de\'df\par \'e0\'e1\'e2\'e3\'e4\'e5\'e6\'e7\'e8\'e9\'ea\'eb\' ec\'ed\'ee\'ef\'f0\'f1\'f2\'f3\'f4\'f5\'f6\'f7\'f8 \'f9\'fa\'fb\'fc\'fd\'fe\'ff\par \lang1033\f0\par } Last edited by nsg; 02-25-2009 at 09:21 PM. |
Advert | |
|
02-25-2009, 09:51 PM | #6 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
any2epub test.rtf
works for me. You can then convert the epub to LRF if you want. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Encoding | prusaks | Recipes | 0 | 09-27-2010 06:25 AM |
how to tell the character encoding??? | rheostaticsfan | Calibre | 23 | 06-21-2010 03:26 PM |
Encoding of Emdash | crutledge | Workshop | 10 | 10-27-2009 08:31 PM |
Language and Encoding Question | llhots | Calibre | 1 | 02-11-2009 10:01 PM |
Need help with text encoding | daesdaemar | Workshop | 12 | 12-31-2008 11:54 AM |