libwps_tools_win.h
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 /* libwps
3  * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
4  * Copyright (C) 2006, 2007 Andrew Ziem
5  * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
6  * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
7  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  *
23  * For further information visit http://libwps.sourceforge.net
24  */
25 
26 /* "This product is not manufactured, approved, or supported by
27  * Corel Corporation or Corel Corporation Limited."
28  */
29 
30 /* This header contains code specific to windows file :
31  * - a class used to convert DOS/Win3 font characters in unicode
32  * - a class used to defined the text Language
33  */
34 
35 #ifndef WPS_WIN
36 # define WPS_WIN
37 
38 # include <assert.h>
39 # include <string>
40 
41 # include "libwps_internal.h"
42 
44 namespace libwps_tools_win
45 {
47 class Font
48 {
49 public:
51  enum Type { DOS_850,
55  };
56 
58  static unsigned long unicode(unsigned char c, Type type)
59  {
60  switch(type)
61  {
62  case DOS_850:
63  return unicodeFromCP850(c);
64  case WIN3_ARABIC:
65  return unicodeFromCP1256(c);
66  case WIN3_BALTIC:
67  return unicodeFromCP1257(c);
68  case WIN3_CEUROPE:
69  return unicodeFromCP1250(c);
70  case WIN3_CYRILLIC:
71  return unicodeFromCP1251(c);
72  case WIN3_GREEK:
73  return unicodeFromCP1253(c);
74  case WIN3_HEBREW:
75  return unicodeFromCP1255(c);
76  case WIN3_TURKISH:
77  return unicodeFromCP1254(c);
78  case WIN3_VIETNAMESE:
79  return unicodeFromCP1258(c);
80  case WIN3_WEUROPE:
81  return unicodeFromCP1252(c);
82  default:
83  assert(0);
84  return c;
85  }
86  }
87 
93  static Type getWin3Type(std::string &name);
94 
95 protected:
96  //
97  // DOS FONTS
98  //
99 
101  static unsigned long unicodeFromCP850(unsigned char c);
102 
104  static unsigned long unicodeFromCP1250(unsigned char c);
106  static unsigned long unicodeFromCP1251(unsigned char c);
108  static unsigned long unicodeFromCP1252(unsigned char c);
110  static unsigned long unicodeFromCP1253(unsigned char c);
112  static unsigned long unicodeFromCP1254(unsigned char c);
114  static unsigned long unicodeFromCP1255(unsigned char c);
116  static unsigned long unicodeFromCP1256(unsigned char c);
118  static unsigned long unicodeFromCP1257(unsigned char c);
120  static unsigned long unicodeFromCP1258(unsigned char c);
121 };
122 
123 // see http://msdn.microsoft.com/en-us/library/bb213877.aspx (Community Content)
125 namespace Language
126 {
128 std::string name(long id);
130 std::string localeName(long id);
132 long getDefault();
133 }
134 
135 }
136 
137 
138 #endif
139 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Wed Aug 8 2012 16:07:55 for libwps by doxygen 1.8.1.2