Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Related Tools

Notices

Reply
 
Thread Tools Search this Thread
Old 12-30-2014, 01:19 AM   #1
jammer699669
Junior Member
jammer699669 began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Dec 2014
Device: android
Syntax using ebook-Covert in PHP

syntax either will make or break the routine

I set up the 1.48 version on a headless server because the server doesn't have the correct libs for the new version
regular call with nothing extra and hoping that the converter will do everything fine
exec("ebook-convert ".$INepub." ". $OutMobi." 2>&1 ",$output);

exec("ebook-convert ".$INepub." ". $OutMobi." --authors \"$Taname\" --publisher \"$pub\" --comments \"$comments\" --tags \"$tags\" --pubdate \"$pubdate\" --isbn \"$spidout\" --title \"$Ttitle\" 2>&1 ",$output);
Spoiler:

The important part about this routine is that if you have any spaces in a string , you must escape the var or it will crash

AS well it does not handle UTF8 coding when sending so you have to strip any of that out from the var ahead of time

I use a function like this to do that
function ITSconvertchars( $str )
{
$str = str_replace( 'À', 'A', $str );
$str = str_replace( 'Á', 'A', $str );
$str = str_replace( 'Â', 'A', $str );
$str = str_replace( 'Ã', 'A', $str );
$str = str_replace( 'Ä', 'A', $str );
$str = str_replace( 'Å', 'A', $str );
$str = str_replace( 'Æ', 'A', $str );
$str = str_replace( 'Ç', 'C', $str );
$str = str_replace( 'È', 'E', $str );
$str = str_replace( 'É', 'E', $str );
$str = str_replace( 'Ê', 'E', $str );
$str = str_replace( 'Ë', 'E', $str );
$str = str_replace( 'Ì', 'I', $str );
$str = str_replace( 'Í', 'I', $str );
$str = str_replace( 'Î', 'I', $str );
$str = str_replace( 'Ï', 'I', $str );
$str = str_replace( 'Ð', 'D', $str );
$str = str_replace( 'Ñ', 'N', $str );
$str = str_replace( 'Ò', 'O', $str );
$str = str_replace( 'Ó', 'O', $str );
$str = str_replace( 'Ô', 'O', $str );
$str = str_replace( 'Õ', 'O', $str );
$str = str_replace( 'Ö', 'O', $str );
$str = str_replace( '×', 'x', $str );
$str = str_replace( 'Ø', 'O', $str );
$str = str_replace( 'Ù', 'U', $str );
$str = str_replace( 'Ú', 'U', $str );
$str = str_replace( 'Û', 'U', $str );
$str = str_replace( 'Ü', 'U', $str );
$str = str_replace( 'Ý', 'Y', $str );
$str = str_replace( 'Þ', 'p', $str );
$str = str_replace( 'ß', 'b', $str );
$str = str_replace( 'à', 'a', $str );
$str = str_replace( 'á', 'a', $str );
$str = str_replace( 'â', 'a', $str );
$str = str_replace( 'ã', 'a', $str );
$str = str_replace( 'ä', 'a', $str );
$str = str_replace( 'å', 'a', $str );
$str = str_replace( 'æ', 'a', $str );
$str = str_replace( 'ç', 'c', $str );
$str = str_replace( 'è', 'e', $str );
$str = str_replace( 'é', 'e', $str );
$str = str_replace( 'ê', 'e', $str );
$str = str_replace( 'ë', 'e', $str );
$str = str_replace( 'ì', 'i', $str );
$str = str_replace( 'í', 'i', $str );
$str = str_replace( 'î', 'i', $str );
$str = str_replace( 'ï', 'i', $str );
$str = str_replace( 'ð', 'o', $str );
$str = str_replace( 'ñ', 'n', $str );
$str = str_replace( 'ò', 'o', $str );
$str = str_replace( 'ó', 'o', $str );
$str = str_replace( 'ô', 'o', $str );
$str = str_replace( 'õ', 'o', $str );
$str = str_replace( 'ö', 'o', $str );
$str = str_replace( '÷', '', $str );
$str = str_replace( 'ø', 'o;', $str );
$str = str_replace( 'ù', 'u', $str );
$str = str_replace( 'ú', 'u', $str );
$str = str_replace( 'û', 'u', $str );
$str = str_replace( 'ü', 'u', $str );
$str = str_replace( 'ý', 'y', $str );
$str = str_replace( 'þ', ';', $str );
// ms word replacements
$str = str_replace( '‚', ",", $str ); // 130 or ‚ or chr(130) = ‚
$str = str_replace( 'ƒ', 'NLG', $str ); //131 or ƒ or chr(131) = ƒ

$str = str_replace( '„', '"', $str ); //132 or „ or chr(132) = „
$str = str_replace( '…', '...', $str ); //133 or … or chr(133) = …
$str = str_replace( '†', '**', $str ); //134 or † or chr(134) = †
$str = str_replace( '‡', '***', $str ); //135 or ‡ or chr(135) = ‡
$str = str_replace( 'ˆ', '^', $str ); //136 or ˆ or chr(136) = ˆ
$str = str_replace( '‰', 'o/oo', $str ); //137 or ‰ or chr(137) = ‰
$str = str_replace( 'Š', 'Sh', $str ); //138 or Š or chr(138) = Š
$str = str_replace( '‹', '<', $str ); //139 or ‹ or chr(139) = ‹
$str = str_replace( 'Œ', 'OE', $str ); //140 or Œ or chr(140) = Œ
$str = str_replace( '‘', "'", $str ); //145 or ‘ or chr(145) = ‘
$str = str_replace( '’', "'", $str );// 146 or ’ or chr(146) = ’
$str = str_replace( '“', '"', $str ); // 147 or “ or chr(147) = “
$str = str_replace( '”', '"', $str ); // 148 or ” or chr(148) = ”
$str = str_replace( '•', '-', $str ); // 149 or • or chr(149) = •
$str = str_replace( '–', '--', $str ); // 150 or – or chr(150) = –
$str = str_replace( '—', '-', $str ); // 151 or — or chr(151) = —
$str = str_replace( '˜', '~', $str ); // 152 or ˜ or chr(152) = ˜
$str = str_replace( '™', '(TM)', $str ); // 153 or ™ or chr(153) = ™
$str = str_replace( 'š', 'sh', $str ); // 154 or š or chr(154) = š
$str = str_replace( '›', '>', $str ); // 155 or › or chr(155) = ›
$str = str_replace( 'œ', 'oe', $str ); // 156 or œ or chr(156) = œ
$str = str_replace( 'Ÿ', 'Y', $str ); // 159 or Ÿ or chr(159) = Ÿ

}


Hope this helps someone

Last edited by theducks; 12-30-2014 at 09:38 AM. Reason: Wrapped long paste in Spoiler
jammer699669 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ebook covert Recipe to .mobi in cmd error coslada Conversion 2 01-13-2013 05:16 AM
Call ebook-convert from PHP using exec/shell_exec techsp123 Conversion 1 07-13-2012 10:47 AM
ebook-convert syntax breakdown lordvetinari2 Calibre 0 06-18-2010 06:35 PM
Running ebook-convert from php conryf Calibre 7 05-24-2010 05:24 AM


All times are GMT -4. The time now is 09:07 AM.


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