"Fossies" - the Fresh Open Source Software Archive

Member "le-1.16.8/src/rus.cc" (18 Mar 2013, 2815 Bytes) of package /linux/misc/le-1.16.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "rus.cc" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 1993-1997 by Alexander V. Lukyanov (lav@yars.free.net)
    3  *
    4  * This program is free software; you can redistribute it and/or modify
    5  * it under the terms of the GNU General Public License as published by
    6  * the Free Software Foundation; either version 2 of the License, or
    7  * (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12  * GNU General Public License for more details.
   13  *
   14  * You should have received a copy of the GNU General Public License
   15  * along with this program; if not, write to the Free Software
   16  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   17  */
   18 
   19 #include <config.h>
   20 #include "edit.h"
   21 #include "rus.h"
   22 
   23 int   coding=0;
   24 
   25 int   isrussian(byte ch)
   26 {
   27    switch(coding)
   28    {
   29    case(KOI8):
   30       return(ch>=0xC0);
   31    case(D211_KOI):
   32       return(ch>=0xC0 && ch!=0xFF && ch!=0xDF);
   33    case(JO_ALT):
   34       return((ch>=0x80 && ch<0xB0) || (ch>=0xE0 && ch<0xF2));
   35    case(ALT):
   36       return((ch>=0x80 && ch<0xB0) || (ch>=0xE0 && ch<0xF0));
   37    case(MAIN):
   38       return(ch>=0xB0 && ch<0xF2);
   39    }
   40    return(0);
   41 }
   42 int   islowerrus(byte ch)
   43 {
   44    switch(coding)
   45    {
   46    case(KOI8):
   47       return(ch>=0xC0 && ch<0xE0);
   48    case(D211_KOI):
   49       return(ch>=0xE0 && ch<0xFF);
   50    case(JO_ALT):
   51       return((ch>=0xA0 && ch<0xB0) || (ch>=0xE0 && ch<0xF1));
   52    case(ALT):
   53       return((ch>=0xA0 && ch<0xB0) || (ch>=0xE0 && ch<0xF0));
   54    case(MAIN):
   55       return(ch>=0xD0 && ch<0xF1);
   56    }
   57    return(0);
   58 }
   59 int   isupperrus(byte ch)
   60 {
   61    switch(coding)
   62    {
   63    case(KOI8):
   64       return(ch>=0xE0);
   65    case(D211_KOI):
   66       return(ch>=0xC0 && ch<0xDF);
   67    case(JO_ALT):
   68       return((ch>=0x80 && ch<0xA0) || ch==0xF1);
   69    case(ALT):
   70       return(ch>=0x80 && ch<0xA0);
   71    case(MAIN):
   72       return((ch>=0xB0 && ch<0xD0) || ch==0xF1);
   73    }
   74    return(0);
   75 }
   76 byte  tolowerrus(byte ch)
   77 {
   78    if(!isupperrus(ch))
   79       return(ch);
   80 
   81     switch(coding)
   82    {
   83    case(KOI8):
   84       return(ch-0x20);
   85    case(D211_KOI):
   86       return(ch+0x20);
   87    case(JO_ALT):
   88       if(ch==0xF0)
   89          return(0xF1);
   90    case(ALT):
   91       if(ch>=0x80 && ch<0x90)
   92          return(ch+0x20);
   93       return(ch+0x50);
   94    case(MAIN):
   95       if(ch==0xF0)
   96          return(0xF1);
   97       return(ch+0x20);
   98    }
   99    return(ch);
  100 }
  101 byte  toupperrus(byte ch)
  102 {
  103    if(!islowerrus(ch))
  104       return(ch);
  105 
  106    switch(coding)
  107    {
  108    case(KOI8):
  109       return(ch+0x20);
  110    case(D211_KOI):
  111       return(ch-0x20);
  112    case(JO_ALT):
  113       if(ch==0xF1)
  114          return(0xF0);
  115    case(ALT):
  116       if(ch>=0xE0 && ch<0xF0)
  117          return(ch-0x50);
  118       return(ch-0x20);
  119    case(MAIN):
  120       if(ch==0xF1)
  121          return(0xF0);
  122       return(ch-0x20);
  123    }
  124    return(ch);
  125 }