1 /***************************************************************************
2  *   Copyright (C) 2007 by Dominik Seichter                                *
3  *   domseichter@web.de                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU Library General Public License as       *
7  *   published by the Free Software Foundation; either version 2 of the    *
8  *   License, or (at your option) any later version.                       *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU Library General Public     *
16  *   License along with this program; if not, write to the                 *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  *                                                                         *
20  *   In addition, as a special exception, the copyright holders give       *
21  *   permission to link the code of portions of this program with the      *
22  *   OpenSSL library under certain conditions as described in each         *
23  *   individual source file, and distribute linked combinations            *
24  *   including the two.                                                    *
25  *   You must obey the GNU General Public License in all respects          *
26  *   for all of the code used other than OpenSSL.  If you modify           *
27  *   file(s) with this exception, you may extend this exception to your    *
28  *   version of the file(s), but you are not obligated to do so.  If you   *
29  *   do not wish to do so, delete this exception statement from your       *
30  *   version.  If you delete this exception statement from all source      *
31  *   files in the program, then also delete it here.                       *
32  ***************************************************************************/
33 
34 #ifndef _PDF_ENCODING_H_
35 #define _PDF_ENCODING_H_
36 
37 #include "PdfDefines.h"
38 #include "PdfName.h"
39 #include "PdfString.h"
40 #include "util/PdfMutex.h"
41 
42 #include <iterator>
43 
44 namespace PoDoFo {
45 
46 class PdfDictionary;
47 class PdfFont;
48 class PdfObject;
49 
50 /**
51  * A PdfEncoding is in PdfFont to transform a text string
52  * into a representation so that it can be displayed in a
53  * PDF file.
54  *
55  * PdfEncoding can also be used to convert strings from a
56  * PDF file back into a PdfString.
57  */
58 class PODOFO_API PdfEncoding {
59  protected:
60     /**
61      *  Create a new PdfEncoding.
62      *
63      *  \param nFirstChar the first supported character code
64      *                    (either a byte value in the current encoding or a unicode value)
65      *  \param nLastChar the last supported character code, must be larger than nFirstChar
66      *                    (either a byte value in the current encoding or a unicode value)
67      *
68      */
69     PdfEncoding( int nFirstChar, int nLastChar, PdfObject* = NULL );
70 
71     /** Get a unique ID for this encoding
72      *  which can used for comparisons!
73      *
74      *  \returns a unique id for this encoding!
75      */
76     virtual const PdfName & GetID() const = 0;
77 
78  public:
79 #if defined(_MSC_VER)  &&  _MSC_VER <= 1200			// ab Visualstudio 6
80     class PODOFO_API const_iterator : public std::iterator<
81                                              std::forward_iterator_tag,
82 						 int, ptrdiff_t> {
83 #else
84     class PODOFO_API const_iterator : public std::iterator<
85                                              std::forward_iterator_tag,
86 						 int, std::ptrdiff_t,
87 						 const int *, const int &> {
88 #endif
89     public:
const_iterator(const PdfEncoding * pEncoding,int nCur)90 	const_iterator( const PdfEncoding* pEncoding, int nCur )
91 	    : m_pEncoding( pEncoding ), m_nCur( nCur )
92 	{
93 	}
94 
const_iterator(const const_iterator & rhs)95 	const_iterator( const const_iterator & rhs )
96 	{
97 	    this->operator=(rhs);
98 	}
99 
100 	const const_iterator & operator=( const const_iterator & rhs )
101 	{
102 	    m_nCur      = rhs.m_nCur;
103 	    m_pEncoding = rhs.m_pEncoding;
104 
105 	    return *this;
106 	}
107 
108 	inline bool operator==( const const_iterator & rhs ) const
109 	{
110 	    return (m_nCur == rhs.m_nCur);
111 	}
112 
113 	inline bool operator!=( const const_iterator & rhs ) const
114 	{
115 	    return (m_nCur != rhs.m_nCur);
116 	}
117 
118 	inline pdf_utf16be operator*() const
119 	{
120 	    return m_pEncoding->GetCharCode( m_nCur );
121 	}
122 
123 	inline const_iterator & operator++()
124 	{
125 	    m_nCur++;
126 
127 	    return *this;
128 	}
129 
130     private:
131 	const PdfEncoding* m_pEncoding;
132 	int                m_nCur;
133     };
134 
135     virtual ~PdfEncoding();
136 
137     /** Comparison operator.
138      *
139      *  \param rhs the PdfEncoding to which this encoding should be compared
140      *
141      *  \returns true if both encodings are the same.
142      */
143     inline bool operator==( const PdfEncoding & rhs ) const;
144 
145     /** Comparison operator.
146      *
147      *  \param rhs the PdfEncoding to which this encoding should be compared
148      *
149      *  \returns true if this encoding is less than the specified.
150      */
151     inline bool operator<( const PdfEncoding & rhs ) const;
152 
153     /** Add this encoding object to a dictionary
154      *  usually be adding an /Encoding key in font dictionaries.
155      *
156      *  \param rDictionary add the encoding to this dictionary
157      */
158     virtual void AddToDictionary( PdfDictionary & rDictionary ) const = 0;
159 
160     /** Convert a string that is encoded with this encoding
161      *  to an unicode PdfString.
162      *
163      *  \param rEncodedString a string encoded by this encoding.
164      *         Usually this string was read from a content stream.
165      *  \param pFont the font for which this string is converted
166      *
167      *  \returns an unicode PdfString.
168      */
169     virtual PdfString ConvertToUnicode( const PdfString & rEncodedString, const PdfFont* pFont ) const;
170 
171     /** Convert a unicode PdfString to a string encoded with this encoding.
172      *
173      *  \param rString an unicode PdfString.
174      *  \param pFont the font for which this string is converted
175      *
176      *  \returns an encoded PdfRefCountedBuffer. The PdfRefCountedBuffer is treated as a series of bytes
177      *           and is allowed to have 0 bytes. The returned buffer must not be a unicode string.
178      */
179     virtual PdfRefCountedBuffer ConvertToEncoding( const PdfString & rString, const PdfFont* pFont ) const;
180 
181     virtual bool IsAutoDelete() const = 0;
182 
183     virtual bool IsSingleByteEncoding() const = 0;
184 
185     /**
186      * \returns the first character code that is defined for this encoding
187      */
188     inline int GetFirstChar() const;
189 
190     /**
191      * \returns the last character code that is defined for this encoding
192      */
193     inline int GetLastChar() const;
194 
195     /** Iterate over all unicode character points in this
196      *  encoding, beginning with the first.
197      *
198      *  \returns iterator pointing to the first defined unicode character
199      */
200     inline const_iterator begin() const;
201 
202     /** Iterate over all unicode character points in this
203      *  encoding, beginning with the first.
204      *
205      *  \returns iterator pointing at the end
206      */
207     inline const_iterator end() const;
208 
209     /** Get the unicode character code for this encoding
210      *  at the position nIndex. nIndex is a position between
211      *  GetFirstChar() and GetLastChar()
212      *
213      *  \param nIndex character code at position index
214      *  \returns unicode character code
215      *
216      *  \see GetFirstChar
217      *  \see GetLastChar
218      *
219      *  Will throw an exception if nIndex is out of range.
220      */
221     virtual pdf_utf16be GetCharCode( int nIndex ) const = 0;
222 
223  protected:
224     bool m_bToUnicodeIsLoaded;  ///< If true, ToUnicode has been parse
225 
226  private:
227     int     m_nFirstChar;   ///< The first defined character code
228     int     m_nLastChar;    ///< The last defined character code
229     const PdfObject* m_pToUnicode;    ///< Pointer to /ToUnicode object, if any
230  protected:
231     std::map<pdf_utf16be, pdf_utf16be> m_toUnicode;
232 
233     pdf_utf16be GetUnicodeValue( pdf_utf16be ) const;
234  private:
235 
236     /** Parse the /ToUnicode object
237     */
238     void ParseToUnicode();
239     pdf_utf16be GetCIDValue( pdf_utf16be ) const;
240 };
241 
242 // -----------------------------------------------------
243 //
244 // -----------------------------------------------------
245 inline bool PdfEncoding::operator<( const PdfEncoding & rhs ) const
246 {
247     return (this->GetID() < rhs.GetID());
248 }
249 
250 // -----------------------------------------------------
251 //
252 // -----------------------------------------------------
253 inline bool PdfEncoding::operator==( const PdfEncoding & rhs ) const
254 {
255     return (this->GetID() == rhs.GetID());
256 }
257 
258 // -----------------------------------------------------
259 //
260 // -----------------------------------------------------
GetFirstChar()261 inline int PdfEncoding::GetFirstChar() const
262 {
263     return m_nFirstChar;
264 }
265 
266 // -----------------------------------------------------
267 //
268 // -----------------------------------------------------
GetLastChar()269 inline int PdfEncoding::GetLastChar() const
270 {
271     return m_nLastChar;
272 }
273 
274 // -----------------------------------------------------
275 //
276 // -----------------------------------------------------
begin()277 inline PdfEncoding::const_iterator PdfEncoding::begin() const
278 {
279     return PdfEncoding::const_iterator( this, this->GetFirstChar() );
280 }
281 
282 // -----------------------------------------------------
283 //
284 // -----------------------------------------------------
end()285 inline PdfEncoding::const_iterator PdfEncoding::end() const
286 {
287     return PdfEncoding::const_iterator( this, this->GetLastChar() + 1 );
288 }
289 
290 /**
291  * A common base class for standard PdfEncoding which are
292  * known by name.
293  *
294  *  - PdfDocEncoding (only use this for strings which are not printed
295  *                    in the document. This is for meta data in the PDF).
296  *  - MacRomanEncoding
297  *  - WinAnsiEncoding
298  *  - MacExpertEncoding
299  *  - StandardEncoding
300  *  - SymbolEncoding
301  *  - ZapfDingbatsEncoding
302  *
303  *  \see PdfWinAnsiEncoding
304  *  \see PdfMacRomanEncoding
305  *  \see PdfMacExportEncoding
306  *..\see PdfStandardEncoding
307  *  \see PdfSymbolEncoding
308  *  \see PdfZapfDingbatsEncoding
309  *
310  */
311 class PODOFO_API PdfSimpleEncoding : public PdfEncoding {
312  public:
313     /*
314      *  Create a new simple PdfEncoding which uses 1 byte.
315      *
316      *  \param rName the name of a standard PdfEncoding
317      *
318      *  As of now possible values for rName are:
319      *  - MacRomanEncoding
320      *  - WinAnsiEncoding
321      *  - MacExpertEncoding
322      *  - StandardEncoding
323      *  - SymbolEncoding
324      *  - ZapfDingbatsEncoding
325      *
326      *  \see PdfWinAnsiEncoding
327      *  \see PdfMacRomanEncoding
328      *  \see PdfMacExportEncoding
329      *  \see PdfStandardEncoding
330      *  \see PdfSymbolEncoding
331      *  \see PdfZapfDingbatsEncoding
332      *
333      *  This will allocate a table of 65535 short values
334      *  to make conversion from unicode to encoded strings
335      *  faster. As this requires a lot of memory, make sure that
336      *  only one object of a certain encoding exists at one
337      *  time, which is no problem as all methods are const anyways!
338      *
339      */
340     PdfSimpleEncoding( const PdfName & rName );
341 
342     ~PdfSimpleEncoding();
343 
344     /** Add this encoding object to a dictionary
345      *  usually be adding an /Encoding key in font dictionaries.
346      *
347      *  \param rDictionary add the encoding to this dictionary
348      */
349     virtual void AddToDictionary( PdfDictionary & rDictionary ) const;
350 
351     /** Convert a string that is encoded with this encoding
352      *  to an unicode PdfString.
353      *
354      *  \param rEncodedString a string encoded by this encoding.
355      *         Usually this string was read from a content stream.
356      *  \param pFont the font for which this string is converted
357      *
358      *  \returns an unicode PdfString.
359      */
360     virtual PdfString ConvertToUnicode( const PdfString & rEncodedString, const PdfFont* pFont ) const;
361 
362     /** Convert a unicode PdfString to a string encoded with this encoding.
363      *
364      *  \param rString an unicode PdfString.
365      *  \param pFont the font for which this string is converted
366      *
367      *  \returns an encoded PdfRefCountedBuffer. The PdfRefCountedBuffer is treated as a series of bytes
368      *           and is allowed to have 0 bytes. The returned buffer must not be a unicode string.
369      */
370     virtual PdfRefCountedBuffer ConvertToEncoding( const PdfString & rString, const PdfFont* pFont ) const;
371 
372     /**
373      * PdfSimpleEncoding subclasses are usuylla not auto-deleted, as
374      * they are allocated statically only once.
375      *
376      * \returns true if this encoding should be deleted automatically with the
377      *          font.
378      *
379      * \see PdfFont::WinAnsiEncoding
380      * \see PdfFont::MacRomanEncoding
381      */
382     virtual bool IsAutoDelete() const;
383 
384     /**
385      *  \returns true if this is a single byte encoding with a maximum of 256 values.
386      */
387     inline virtual bool IsSingleByteEncoding() const;
388 
389     /** Get the name of this encoding.
390      *
391      *  \returns the name of this encoding.
392      */
393     inline const PdfName & GetName() const;
394 
395     /** Get the unicode character code for this encoding
396      *  at the position nIndex. nIndex is a position between
397      *  GetFirstChar() and GetLastChar()
398      *
399      *  \param nIndex character code at position index
400      *  \returns unicode character code
401      *
402      *  \see GetFirstChar
403      *  \see GetLastChar
404      *
405      *  Will throw an exception if nIndex is out of range.
406      */
407     virtual pdf_utf16be GetCharCode( int nIndex ) const;
408 
409     char GetUnicodeCharCode(pdf_utf16be unicodeValue) const;
410 
411  private:
412     /** Initialize the internal table of mappings from unicode code points
413      *  to encoded byte values.
414      */
415     void InitEncodingTable();
416 
417  protected:
418 
419     /** Get a unique ID for this encoding
420      *  which can used for comparisons!
421      *
422      *  \returns a unique id for this encoding!
423      */
424     inline virtual const PdfName & GetID() const;
425 
426     /** Gets a table of 256 short values which are the
427      *  big endian unicode code points that are assigned
428      *  to the 256 values of this encoding.
429      *
430      *  This table is used internally to convert an encoded
431      *  string of this encoding to and from unicode.
432      *
433      *  \returns an array of 256 big endian unicode code points
434      */
435     virtual const pdf_utf16be* GetToUnicodeTable() const = 0;
436 
437  protected:
438     Util::PdfMutex * m_mutex;   ///< Mutex for the creation of the encoding table
439 
440  private:
441     PdfName m_name;           ///< The name of the encoding
442     char*   m_pEncodingTable; ///< The helper table for conversions into this encoding
443 };
444 
445 // -----------------------------------------------------
446 //
447 // -----------------------------------------------------
GetID()448 inline const PdfName & PdfSimpleEncoding::GetID() const
449 {
450     return m_name;
451 }
452 
453 // -----------------------------------------------------
454 //
455 // -----------------------------------------------------
IsAutoDelete()456 inline bool PdfSimpleEncoding::IsAutoDelete() const
457 {
458     return false;
459 }
460 
461 // -----------------------------------------------------
462 //
463 // -----------------------------------------------------
IsSingleByteEncoding()464 inline bool PdfSimpleEncoding::IsSingleByteEncoding() const
465 {
466     return true;
467 }
468 
469 // -----------------------------------------------------
470 //
471 // -----------------------------------------------------
GetName()472 inline const PdfName & PdfSimpleEncoding::GetName() const
473 {
474     return m_name;
475 }
476 
477 /**
478  * The PdfDocEncoding is the default encoding for
479  * all strings in PoDoFo which are data in the PDF
480  * file.
481  *
482  * Do not allocate this class yourself, as allocations
483  * might be expensive. Try using PdfFont::DocEncoding.
484  *
485  * \see PdfFont::DocEncoding
486  */
487 class PODOFO_API PdfDocEncoding : public PdfSimpleEncoding {
488  public:
489 
490     /** Create a new PdfDocEncoding
491      */
PdfDocEncoding()492     PdfDocEncoding()
493         : PdfSimpleEncoding( PdfName("PdfDocEncoding") )
494     {
495 
496     }
497 
498  protected:
499 
500     /** Gets a table of 256 short values which are the
501      *  big endian unicode code points that are assigned
502      *  to the 256 values of this encoding.
503      *
504      *  This table is used internally to convert an encoded
505      *  string of this encoding to and from unicode.
506      *
507      *  \returns an array of 256 big endian unicode code points
508      */
509     virtual const pdf_utf16be* GetToUnicodeTable() const;
510 
511  private:
512     static const pdf_utf16be s_cEncoding[256]; ///< conversion table from DocEncoding to UTF16
513 
514 };
515 
516 /**
517  * The WinAnsi Encoding is the default encoding in PoDoFo for
518  * contents on PDF pages.
519  *
520  * It is also called CP-1252 encoding.
521  * This class may be used as base for derived encodings.
522  *
523  * \see PdfWin1250Encoding
524  *
525  * Do not allocate this class yourself, as allocations
526  * might be expensive. Try using PdfFont::WinAnsiEncoding.
527  *
528  * \see PdfFont::WinAnsiEncoding
529  */
530 class PODOFO_API PdfWinAnsiEncoding : public PdfSimpleEncoding {
531  public:
532 
533     /** Create a new PdfWinAnsiEncoding
534      */
PdfWinAnsiEncoding()535     PdfWinAnsiEncoding()
536         : PdfSimpleEncoding( PdfName("WinAnsiEncoding") )
537     {
538 
539     }
540 
541  protected:
542 
543     /** Gets a table of 256 short values which are the
544      *  big endian unicode code points that are assigned
545      *  to the 256 values of this encoding.
546      *
547      *  This table is used internally to convert an encoded
548      *  string of this encoding to and from unicode.
549      *
550      *  \returns an array of 256 big endian unicode code points
551      */
552     virtual const pdf_utf16be* GetToUnicodeTable() const;
553 
554     /** Add this encoding object to a dictionary
555      *  usually be adding an /Encoding key in font dictionaries.
556      *
557      *  This method generates array of differences into /Encoding
558      *  dictionary if called from derived class with
559      *  different unicode table.
560      *
561      *  \param rDictionary add the encoding to this dictionary
562      */
563     virtual void AddToDictionary( PdfDictionary & rDictionary ) const;
564 
565  private:
566     static const pdf_utf16be s_cEncoding[256]; ///< conversion table from WinAnsiEncoding to UTF16
567 
568 };
569 
570 /**
571  * Do not allocate this class yourself, as allocations
572  * might be expensive. Try using PdfFont::MacRomanEncoding.
573  *
574  * \see PdfFont::MacRomanEncoding
575  */
576 class PODOFO_API PdfMacRomanEncoding : public PdfSimpleEncoding {
577  public:
578 
579     /** Create a new PdfMacRomanEncoding
580      */
PdfMacRomanEncoding()581     PdfMacRomanEncoding()
582         : PdfSimpleEncoding( PdfName("MacRomanEncoding") )
583     {
584 
585     }
586 
587  protected:
588 
589     /** Gets a table of 256 short values which are the
590      *  big endian unicode code points that are assigned
591      *  to the 256 values of this encoding.
592      *
593      *  This table is used internally to convert an encoded
594      *  string of this encoding to and from unicode.
595      *
596      *  \returns an array of 256 big endian unicode code points
597      */
598     virtual const pdf_utf16be* GetToUnicodeTable() const;
599 
600  private:
601     static const pdf_utf16be s_cEncoding[256]; ///< conversion table from MacRomanEncoding to UTF16
602 
603 };
604 
605 /**
606  */
607 class PODOFO_API PdfMacExpertEncoding : public PdfSimpleEncoding {
608  public:
609 
610     /** Create a new PdfMacExpertEncoding
611      */
PdfMacExpertEncoding()612     inline PdfMacExpertEncoding()
613         : PdfSimpleEncoding( PdfName("MacExpertEncoding") )
614     {
615 
616     }
617 
618  protected:
619 
620     /** Gets a table of 256 short values which are the
621      *  big endian unicode code points that are assigned
622      *  to the 256 values of this encoding.
623      *
624      *  This table is used internally to convert an encoded
625      *  string of this encoding to and from unicode.
626      *
627      *  \returns an array of 256 big endian unicode code points
628      */
629     virtual const pdf_utf16be* GetToUnicodeTable() const;
630 
631  private:
632     static const pdf_utf16be s_cEncoding[256]; ///< conversion table from MacExpertEncoding to UTF16
633 
634 };
635 
636 // OC 13.08.2010 Neu: StandardEncoding
637 /**
638  * Do not allocate this class yourself, as allocations
639  * might be expensive. Try using PdfFont::StandardEncoding.
640  *
641  * \see PdfFont::StandardEncoding
642  */
643 class PODOFO_API PdfStandardEncoding : public PdfSimpleEncoding {
644  public:
645 
646     /** Create a new PdfStandardEncoding
647      */
PdfStandardEncoding()648     PdfStandardEncoding()
649         : PdfSimpleEncoding( PdfName("StandardEncoding") )
650     {
651 
652     }
653 
654  protected:
655 
656     /** Gets a table of 256 short values which are the
657      *  big endian unicode code points that are assigned
658      *  to the 256 values of this encoding.
659      *
660      *  This table is used internally to convert an encoded
661      *  string of this encoding to and from unicode.
662      *
663      *  \returns an array of 256 big endian unicode code points
664      */
665     virtual const pdf_utf16be* GetToUnicodeTable() const;
666 
667  private:
668     static const pdf_utf16be s_cEncoding[256]; ///< conversion table from StandardEncoding to UTF16
669 
670 };
671 
672 // OC 13.08.2010 Neu: SymbolEncoding
673 /**
674  * Do not allocate this class yourself, as allocations
675  * might be expensive. Try using PdfFont::SymbolEncoding.
676  *
677  * \see PdfFont::SymbolEncoding
678  */
679 class PODOFO_API PdfSymbolEncoding : public PdfSimpleEncoding {
680  public:
681 
682     /** Create a new PdfSymbolEncoding
683      */
PdfSymbolEncoding()684     PdfSymbolEncoding()
685         : PdfSimpleEncoding( PdfName("SymbolEncoding") )
686     {
687 
688     }
689 
690  protected:
691 
692     /** Gets a table of 256 short values which are the
693      *  big endian unicode code points that are assigned
694      *  to the 256 values of this encoding.
695      *
696      *  This table is used internally to convert an encoded
697      *  string of this encoding to and from unicode.
698      *
699      *  \returns an array of 256 big endian unicode code points
700      */
701     virtual const pdf_utf16be* GetToUnicodeTable() const;
702 
703  private:
704     static const pdf_utf16be s_cEncoding[256]; ///< conversion table from SymbolEncoding to UTF16
705 
706 };
707 
708 // OC 13.08.2010 Neu: ZapfDingbatsEncoding
709 /**
710  * Do not allocate this class yourself, as allocations
711  * might be expensive. Try using PdfFont::ZapfDingbats.
712  *
713  * \see PdfFont::ZapfDingbatsEncoding
714  */
715 class PODOFO_API PdfZapfDingbatsEncoding : public PdfSimpleEncoding {
716  public:
717 
718     /** Create a new PdfZapfDingbatsEncoding
719      */
PdfZapfDingbatsEncoding()720     PdfZapfDingbatsEncoding()
721         : PdfSimpleEncoding( PdfName("ZapfDingbatsEncoding") )
722     {
723 
724     }
725 
726  protected:
727 
728     /** Gets a table of 256 short values which are the
729      *  big endian unicode code points that are assigned
730      *  to the 256 values of this encoding.
731      *
732      *  This table is used internally to convert an encoded
733      *  string of this encoding to and from unicode.
734      *
735      *  \returns an array of 256 big endian unicode code points
736      */
737     virtual const pdf_utf16be* GetToUnicodeTable() const;
738 
739  private:
740     static const pdf_utf16be s_cEncoding[256]; ///< conversion table from ZapfDingbatsEncoding to UTF16
741 
742 };
743 
744 /**
745 * WINDOWS-1250 encoding
746 */
747 class PODOFO_API PdfWin1250Encoding : public PdfWinAnsiEncoding
748 {
749  public:
750 
751     /** Create a new PdfWin1250Encoding
752      */
PdfWin1250Encoding()753     PdfWin1250Encoding()
754     {
755         m_id = "Win1250Encoding";
756     }
757 
758  protected:
759 
GetID()760     virtual const PdfName & GetID() const
761     {
762         return m_id;
763     }
764 
765     /** Gets a table of 256 short values which are the
766      *  big endian unicode code points that are assigned
767      *  to the 256 values of this encoding.
768      *
769      *  This table is used internally to convert an encoded
770      *  string of this encoding to and from unicode.
771      *
772      *  \returns an array of 256 big endian unicode code points
773      */
774     virtual const pdf_utf16be* GetToUnicodeTable() const;
775 
776  private:
777     static const pdf_utf16be s_cEncoding[256]; ///< conversion table from Win1250Encoding to UTF16
778     PdfName m_id;
779 };
780 
781 /**
782 * ISO-8859-2 encoding
783 */
784 class PODOFO_API PdfIso88592Encoding : public PdfWinAnsiEncoding
785 {
786  public:
787 
788     /** Create a new PdfIso88592Encoding
789      */
PdfIso88592Encoding()790     PdfIso88592Encoding()
791     {
792         m_id = "Iso88592Encoding";
793     }
794 
795  protected:
796 
GetID()797     virtual const PdfName & GetID() const
798     {
799         return m_id;
800     }
801 
802     /** Gets a table of 256 short values which are the
803      *  big endian unicode code points that are assigned
804      *  to the 256 values of this encoding.
805      *
806      *  This table is used internally to convert an encoded
807      *  string of this encoding to and from unicode.
808      *
809      *  \returns an array of 256 big endian unicode code points
810      */
811     virtual const pdf_utf16be* GetToUnicodeTable() const;
812 
813  private:
814     static const pdf_utf16be s_cEncoding[256]; ///< conversion table from Iso88592Encoding to UTF16
815     PdfName m_id;
816 };
817 
818 }; /* namespace PoDoFo */
819 
820 
821 #endif // _PDF_ENCODING_H_
822 
823