~ubuntu-branches/ubuntu/quantal/poco/quantal

« back to all changes in this revision

Viewing changes to Foundation/src/Windows1252Encoding.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Burghardt
  • Date: 2008-11-15 11:39:15 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081115113915-7kauhm2c3m2i7oid
Tags: 1.3.3p1-2
* Fixed FTBFS with GCC 4.4 due to missing #include (Closes: #505619)
* Renamed 20_gcc43-missing-include.dpatch to 20_gcc44-missing-include.dpatch
* Downgraded dependencies on -dbg packages (Closes: #504342)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
2
// Windows1252Encoding.cpp
3
3
//
4
 
// $Id: //poco/1.3/Foundation/src/Windows1252Encoding.cpp#3 $
 
4
// $Id: //poco/1.3/Foundation/src/Windows1252Encoding.cpp#4 $
5
5
//
6
6
// Library: Foundation
7
7
// Package: Text
36
36
 
37
37
#include "Poco/Windows1252Encoding.h"
38
38
#include "Poco/String.h"
 
39
#include <map>
39
40
 
40
41
 
41
42
namespace Poco {
106
107
 
107
108
int Windows1252Encoding::convert(const unsigned char* bytes) const
108
109
{
109
 
        return *bytes;
 
110
        return _charMap[*bytes];
110
111
}
111
112
 
112
113
 
113
114
int Windows1252Encoding::convert(int ch, unsigned char* bytes, int length) const
114
115
{
115
 
        if (ch >= 0 && ch <= 255)
 
116
        if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
116
117
        {
117
118
                if (bytes && length >= 1)
118
 
                        *bytes = (unsigned char) ch;
 
119
                        *bytes = ch;
119
120
                return 1;
120
121
        }
121
 
        else return 0;
 
122
        else switch (ch)
 
123
        {
 
124
        case 0x20ac: if (bytes && length >= 1) *bytes = 0x80; return 1;
 
125
        case 0x201a: if (bytes && length >= 1) *bytes = 0x82; return 1;
 
126
        case 0x0192: if (bytes && length >= 1) *bytes = 0x83; return 1;
 
127
        case 0x201e: if (bytes && length >= 1) *bytes = 0x84; return 1;
 
128
        case 0x2026: if (bytes && length >= 1) *bytes = 0x85; return 1;
 
129
        case 0x2020: if (bytes && length >= 1) *bytes = 0x86; return 1;
 
130
        case 0x2021: if (bytes && length >= 1) *bytes = 0x87; return 1;
 
131
        case 0x02c6: if (bytes && length >= 1) *bytes = 0x88; return 1;
 
132
        case 0x2030: if (bytes && length >= 1) *bytes = 0x89; return 1;
 
133
        case 0x0160: if (bytes && length >= 1) *bytes = 0x8a; return 1;
 
134
        case 0x2039: if (bytes && length >= 1) *bytes = 0x8b; return 1;
 
135
        case 0x0152: if (bytes && length >= 1) *bytes = 0x8c; return 1;
 
136
        case 0x017d: if (bytes && length >= 1) *bytes = 0x8e; return 1;
 
137
        case 0x2018: if (bytes && length >= 1) *bytes = 0x91; return 1;
 
138
        case 0x2019: if (bytes && length >= 1) *bytes = 0x92; return 1;
 
139
        case 0x201c: if (bytes && length >= 1) *bytes = 0x93; return 1;
 
140
        case 0x201d: if (bytes && length >= 1) *bytes = 0x94; return 1;
 
141
        case 0x2022: if (bytes && length >= 1) *bytes = 0x95; return 1;
 
142
        case 0x2013: if (bytes && length >= 1) *bytes = 0x96; return 1;
 
143
        case 0x2014: if (bytes && length >= 1) *bytes = 0x97; return 1;
 
144
        case 0x02dc: if (bytes && length >= 1) *bytes = 0x98; return 1;
 
145
        case 0x2122: if (bytes && length >= 1) *bytes = 0x99; return 1;
 
146
        case 0x0161: if (bytes && length >= 1) *bytes = 0x9a; return 1;
 
147
        case 0x203a: if (bytes && length >= 1) *bytes = 0x9b; return 1;
 
148
        case 0x0153: if (bytes && length >= 1) *bytes = 0x9c; return 1;
 
149
        case 0x017e: if (bytes && length >= 1) *bytes = 0x9e; return 1;
 
150
        case 0x0178: if (bytes && length >= 1) *bytes = 0x9f; return 1;
 
151
        default: return 0;
 
152
        }
122
153
}
123
154
 
124
155