"Fossies" - the Fresh Open Source Software Archive

Member "kydpdict-0.9.5/src/ydpconverter.cpp" (23 Jul 2005, 1831 Bytes) of package /linux/privat/old/kydpdict-0.9.5.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 "ydpconverter.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2  *                                                                         *
    3  *   This program is free software; you can redistribute it and/or modify  *
    4  *   it under the terms of the GNU General Public License as published by  *
    5  *   the Free Software Foundation; either version 2 of the License, or     *
    6  *   (at your option) any later version.                                   *
    7  *                                                                         *
    8  ***************************************************************************/
    9 
   10 #include "ydpconverter.h"
   11 
   12 #include <qstring.h>
   13 #include <qcstring.h>
   14 
   15 /////////////////////
   16 // utf16 <-> anything convertion stuff below
   17 //
   18 
   19 ydpConverter::ydpConverter(void) {
   20 }
   21 
   22 ydpConverter::~ydpConverter() {
   23 }
   24 
   25 char ydpConverter::toLower(const char c) {
   26     return c;
   27 }
   28 
   29 char *ydpConverter::toLocal(const char *input) {
   30     return (char*)input;
   31 }
   32 
   33 QString ydpConverter::toUnicode(const char *input) {
   34     return QString(input);
   35 }
   36 
   37 QCString ydpConverter::fromUnicode(QString input) {
   38     return input.ascii();
   39 }
   40 
   41 QString ydpConverter::convertChunk(const char *input, int size, bool unicodeFont) {
   42     return QString(input);
   43 }
   44 
   45 int ydpConverter::charIndex(const char c) {
   46     return c;
   47 }
   48 
   49 int ydpConverter::localeCompare(const char *w1, const char *w2) {
   50     int i = 0;
   51     int len1 = strlen(w1);
   52     int len2 = strlen(w2);
   53     int c1, c2;
   54     for (; ((i<len1) && (i<len2)); i++) {
   55         c1 = charIndex(w1[i]); c2 = charIndex(w2[i]);
   56         if (c1!=c2) {
   57             return c1-c2;
   58         }
   59     }
   60     // identical substrings so longer is bigger
   61     return len1-len2;
   62 }
   63 
   64 int ydpConverter::scoreWord(const char *w1, const char *w2) {
   65     int i = 0;
   66     int len1 = strlen(w1);
   67     int len2 = strlen(w2);
   68     for (; ((i<len1) && (i<len2)); i++)
   69         if (w1[i] != w2[i])
   70             break;
   71     return i;
   72 }