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

#include <utf8latin1.h>

+ Inheritance diagram for UTF8Latin1:
+ Collaboration diagram for UTF8Latin1:

Public Member Functions

virtual const char * getHeader () const
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)
 
 UTF8Latin1 (char rchar= '?')
 

Private Attributes

char replacementChar
 

Detailed Description

This filter converts UTF-8 encoded text to Latin-1

Definition at line 34 of file utf8latin1.h.

Constructor & Destructor Documentation

SWORD_NAMESPACE_START UTF8Latin1::UTF8Latin1 ( char  rchar = '?')

Definition at line 30 of file utf8latin1.cpp.

30  : replacementChar(rchar) {
31 }
char replacementChar
Definition: utf8latin1.h:37

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 UTF8Latin1::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 34 of file utf8latin1.cpp.

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

Member Data Documentation

char UTF8Latin1::replacementChar
private

Definition at line 37 of file utf8latin1.h.


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