ASCIIEncoding.cpp
Go to the documentation of this file.
00001 //
00002 // ASCIIEncoding.cpp
00003 //
00004 // $Id: //poco/1.3/Foundation/src/ASCIIEncoding.cpp#3 $
00005 //
00006 // Library: Foundation
00007 // Package: Text
00008 // Module:  ASCIIEncoding
00009 //
00010 // Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
00011 // and Contributors.
00012 //
00013 // Permission is hereby granted, free of charge, to any person or organization
00014 // obtaining a copy of the software and accompanying documentation covered by
00015 // this license (the "Software") to use, reproduce, display, distribute,
00016 // execute, and transmit the Software, and to prepare derivative works of the
00017 // Software, and to permit third-parties to whom the Software is furnished to
00018 // do so, all subject to the following:
00019 // 
00020 // The copyright notices in the Software and this entire statement, including
00021 // the above license grant, this restriction and the following disclaimer,
00022 // must be included in all copies of the Software, in whole or in part, and
00023 // all derivative works of the Software, unless such copies or derivative
00024 // works are solely in the form of machine-executable object code generated by
00025 // a source language processor.
00026 // 
00027 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00028 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00029 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00030 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00031 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00032 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00033 // DEALINGS IN THE SOFTWARE.
00034 //
00035 
00036 
00037 #include "Poco/ASCIIEncoding.h"
00038 #include "Poco/String.h"
00039 
00040 
00041 namespace Poco {
00042 
00043 
00044 const char* ASCIIEncoding::_names[] =
00045 {
00046         "ASCII",
00047         NULL
00048 };
00049 
00050 
00051 const TextEncoding::CharacterMap ASCIIEncoding::_charMap = 
00052 {
00053         /* 00 */        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
00054         /* 10 */        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 
00055         /* 20 */        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 
00056         /* 30 */        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 
00057         /* 40 */        0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 
00058         /* 50 */        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 
00059         /* 60 */        0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 
00060         /* 70 */        0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 
00061         /* 80 */          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1, 
00062         /* 90 */          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1, 
00063         /* a0 */          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1, 
00064         /* b0 */          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1, 
00065         /* c0 */          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1, 
00066         /* d0 */          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1, 
00067         /* e0 */          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1, 
00068         /* f0 */          -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1, 
00069 };
00070 
00071 
00072 ASCIIEncoding::ASCIIEncoding()
00073 {
00074 }
00075 
00076 
00077 ASCIIEncoding::~ASCIIEncoding()
00078 {
00079 }
00080 
00081 
00082 const char* ASCIIEncoding::canonicalName() const
00083 {
00084         return _names[0];
00085 }
00086 
00087 
00088 bool ASCIIEncoding::isA(const std::string& encodingName) const
00089 {
00090         for (const char** name = _names; *name; ++name)
00091         {
00092                 if (Poco::icompare(encodingName, *name) == 0)
00093                         return true;
00094         }
00095         return false;
00096 }
00097 
00098 
00099 const TextEncoding::CharacterMap& ASCIIEncoding::characterMap() const
00100 {
00101         return _charMap;
00102 }
00103 
00104 
00105 int ASCIIEncoding::convert(const unsigned char* bytes) const
00106 {
00107         return *bytes;
00108 }
00109 
00110 
00111 int ASCIIEncoding::convert(int ch, unsigned char* bytes, int length) const
00112 {
00113         if (ch >= 0 && ch <= 127)
00114         {
00115                 if (bytes && length >= 1)
00116                         *bytes = (unsigned char) ch;
00117                 return 1;
00118         }
00119         else return 0;
00120 }
00121 
00122 
00123 } // namespace Poco


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:19