The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UTF8HTML Class Reference

#include <utf8html.h>

+ Inheritance diagram for UTF8HTML:
+ Collaboration diagram for UTF8HTML:

Public Member Functions

virtual const char * getHeader () const
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)
 
 UTF8HTML ()
 

Detailed Description

This filter converts UTF-8 text into HTML escape sequences

Definition at line 33 of file utf8html.h.

Constructor & Destructor Documentation

SWORD_NAMESPACE_START UTF8HTML::UTF8HTML ( )

Definition at line 32 of file utf8html.cpp.

32  {
33 }

Member Function Documentation

virtual const char* SWFilter::getHeader ( ) const
inlinevirtualinherited

This method can supply a header associated with the processing done with this filter. A typical example is a suggested CSS style block for classed containers.

Reimplemented in OSISLaTeX, OSISXHTML, ThMLLaTeX, ThMLXHTML, TEIXHTML, GBFLaTeX, and GBFXHTML.

Definition at line 62 of file swfilter.h.

62 { return ""; }
char UTF8HTML::processText ( SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
)
virtual

This method processes and appropriately modifies the text given it for a particular filter task

Parameters
textThe text to be filtered/converted
keyCurrent key That was used.
moduleCurrent module.
Returns
0

Implements SWFilter.

Definition at line 36 of file utf8html.cpp.

37 {
38  unsigned char *from;
39  char digit[10];
40  unsigned long ch;
41  if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
42  return (char)-1;
43 
44  SWBuf orig = text;
45  from = (unsigned char *)orig.c_str();
46 
47  // -------------------------------
48  for (text = ""; *from; from++) {
49  ch = 0;
50  if ((*from & 128) != 128) {
51 // if (*from != ' ')
52  text += *from;
53  continue;
54  }
55  if ((*from & 128) && ((*from & 64) != 64)) {
56  // error
57  *from = 'x';
58  continue;
59  }
60  *from <<= 1;
61  int subsequent;
62  for (subsequent = 1; (*from & 128); subsequent++) {
63  *from <<= 1;
64  from[subsequent] &= 63;
65  ch <<= 6;
66  ch |= from[subsequent];
67  }
68  subsequent--;
69  *from <<=1;
70  char significantFirstBits = 8 - (2+subsequent);
71 
72  ch |= (((short)*from) << (((6*subsequent)+significantFirstBits)-8));
73  from += subsequent;
74  text += '&';
75  text += '#';
76  sprintf(digit, "%ld", ch);
77  for (char *dig = digit; *dig; dig++)
78  text += *dig;
79  text += ';';
80  }
81  return 0;
82 }
Definition: swbuf.h:47
const char * c_str() const
Definition: swbuf.h:158

The documentation for this class was generated from the following files: