Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

oem2ansi.cpp

Go to the documentation of this file.
00001 
00002 //
00003 // Copyright (C) 2000
00004 // Ralf Westram
00005 // (Coded@ReallySoft.de)
00006 //
00007 // Permission to use, copy, modify, distribute and sell this software
00008 // and its documentation for any purpose is hereby granted without fee,
00009 // provided that the above copyright notice appear in all copies and
00010 // that both that copyright notice and this permission notice appear
00011 // in supporting documentation.  Ralf Westram makes no
00012 // representations about the suitability of this software for any
00013 // purpose.  It is provided "as is" without express or implied warranty.
00014 //
00015 // This code is part of my library.
00016 // You may find a more recent version at http://www.reallysoft.de/
00017 //
00019 
00020 #include "oem2ansi.h"
00021 
00022 using namespace std;
00023 using namespace rs;
00024 
00025 // --------------------------------------------------------------------------------
00026 
00027 /*
00028 
00029  ANSI - Zeichensatz
00030 
00031     032  !"#$%&'()*+,-./
00032     048 0123456789:;<=>?
00033     064 @ABCDEFGHIJKLMNO
00034     080 PQRSTUVWXYZ[\]^_
00035     096 `abcdefghijklmno
00036     112 pqrstuvwxyz{|}~
00037     128 
00038     144 
00039     160 
00040     176 
00041     192 
00042     208 
00043     224 
00044     240 
00045 
00046 */
00047 
00048 // --------------------------------------------------------------------------------
00049 
00050 namespace rs {
00051     namespace oem2ansi {
00052 
00053         static char oem_to_ansi_tab[] = "?'\"_+^??<?????`'\"\"--~??>????"
00054         "Ͼ"
00055         "ǎԐѥ噞"
00056         "ƄФ";
00057 
00058         static char ansi_to_oem_tab[] = "׃"
00059         "Ѫ+++"
00060         "+--+-+++---+i++_̯"
00061         "յݯ=";
00062 
00063         // --------------------------------------------------------------------------------
00064         //     unsigned char oem_to_ansi(unsigned char c)
00065         // --------------------------------------------------------------------------------
00066         unsigned char oem_to_ansi(unsigned char c)
00067         {
00068             return c<128 ? c : oem_to_ansi_tab[c-128];
00069         }
00070 
00071         // --------------------------------------------------------------------------------
00072         //     unsigned char ansi_to_oem(unsigned char c)
00073         // --------------------------------------------------------------------------------
00074         unsigned char ansi_to_oem(unsigned char c)
00075         {
00076             return c<128 ? c : ansi_to_oem_tab[c-128];
00077         }
00078 
00079         // --------------------------------------------------------------------------------
00080         //     string oem_to_ansi(const string& s)
00081         // --------------------------------------------------------------------------------
00082         string oem_to_ansi(const string& s) {
00083             string neu = s;
00084 
00085             for (string::iterator n=neu.begin(); n!=neu.end(); ++n) {
00086                 *n = oem_to_ansi(*n);
00087             }
00088 
00089             return neu;
00090         }
00091         // --------------------------------------------------------------------------------
00092         //     string ansi_to_oem(const string& s)
00093         // --------------------------------------------------------------------------------
00094         string ansi_to_oem(const string& s) {
00095             string neu = s;
00096 
00097             for (string::iterator n=neu.begin(); n!=neu.end(); ++n) {
00098                 *n = ansi_to_oem(*n);
00099             }
00100 
00101             return neu;
00102         }
00103 
00104     };
00105 };

Contact me in case of errors or questions.
This documentation is powered by Doxygen.
(C) 2000-2002 Doxygen