Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 02-23-2009, 11:02 PM   #1
nsg
Member
nsg began at the beginning.
 
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.
nsg is offline   Reply With Quote
Old 02-24-2009, 12:40 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,749
Karma: 22446736
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?
kovidgoyal is online now   Reply With Quote
Advert
Old 02-24-2009, 07:18 AM   #3
nsg
Member
nsg began at the beginning.
 
Posts: 20
Karma: 10
Join Date: Nov 2007
Device: PRS-505
It has cp1251.pyo file.
(But I do not see cp1251.py)
nsg is offline   Reply With Quote
Old 02-24-2009, 01:36 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,749
Karma: 22446736
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')"
kovidgoyal is online now   Reply With Quote
Old 02-25-2009, 09:18 PM   #5
nsg
Member
nsg began at the beginning.
 
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.
nsg is offline   Reply With Quote
Advert
Old 02-25-2009, 09:51 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,749
Karma: 22446736
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.
kovidgoyal is online now   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 10:03 AM.


MobileRead.com is a privately owned, operated and funded community.