diff options
Diffstat (limited to 'src/modules/filters/rtfhtml.cpp')
-rw-r--r-- | src/modules/filters/rtfhtml.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/modules/filters/rtfhtml.cpp b/src/modules/filters/rtfhtml.cpp index 7b55721..df02f38 100644 --- a/src/modules/filters/rtfhtml.cpp +++ b/src/modules/filters/rtfhtml.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * rtfhtml.cpp - description - * ------------------- - * begin : Wed Oct 13 1999 - * copyright : (C) 1999 by The team of BibleTime - * email : info@bibletime.de * - * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org) + * rtfhtml.cpp - filter to convert RTF to HTML + * + * $Id: rtfhtml.cpp 2981 2013-09-15 00:05:26Z scribe $ + * + * Copyright 1999 The team of Bibletime (info@bibletime.de) + * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society * P. O. Box 2528 * Tempe, AZ 85280-2528 @@ -24,11 +24,14 @@ #include <stdlib.h> #include <rtfhtml.h> #include <swbuf.h> +#include <utilstr.h> +#include <ctype.h> +#include <sysdata.h> SWORD_NAMESPACE_START -RTFHTML::RTFHTML() { - +RTFHTML::RTFHTML() +{ } @@ -43,12 +46,25 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module) { if (*from == '\\') // a RTF command { + // \u12345? + if ( *(from+1) == 'u' && (*(from+2) == '-' || isdigit(*(from+2)))) { + from += 2; + const char *end = from; + while (isdigit(*++end)); + SWBuf num; + num.append(from, end-from); + __s16 n = atoi(num.c_str()); + __u32 u = (__u16)n; + text.append(getUTF8FromUniChar(u)); + from += (end-from); + continue; + } if ( !strncmp(from+1, "pard", 4) ) //(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r') && (from[4] == 'd')) { // switch all modifiers off if (center) { - text += "</CENTER>"; + text += "</center>"; center = false; } from += 4; @@ -57,7 +73,7 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module) if ( !strncmp(from+1, "par", 3) ) //(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r')) { - text += "<P>\n"; + text += "<p/>\n"; from += 3; continue; } @@ -71,7 +87,7 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module) { if (!center) { - text += "<CENTER>"; + text += "<center>"; center = true; } from += 2; |