--- kdisptext.cpp.orig	2002-10-27 04:20:12.000000000 +0600
+++ kdisptext.cpp	2003-07-08 21:35:27.000000000 +0700
@@ -19,6 +19,13 @@
 
     Send comments and bug fixes to larrosa@kde.org
     or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
+    
+
+    This version of the file is "hacked" to convert Russia karaoke files
+    Windows-1251 -> KOI8-R. This allows to play CP1251 karaoke on
+    systems with KOI8-R locale.  Changes are marked by KOI-8 Hack.
+    (C) Sergey A. Galin, 2003, http://sageshome.net  
+    
 
 ***************************************************************************/
 #include "kdisptext.h"
@@ -35,6 +42,36 @@
 #define NUMPREVLINES 2
 //#define DRAW_BOUNDING_RECTS
 
+/* KOI-8 Hack */
+const unsigned char recodetbl[256]={
+  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
+  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 
+  32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+  48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 
+  64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 
+  80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 
+  96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 
+  112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 
+  
+  128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 
+  144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 
+  160, 161, 162, 163, 164, 165, 166, 167, 179, 169, 170, 171, 172, 173, 174, 175, 
+  176, 177, 178, 179, 180, 181, 182, 183, 163, 185, 186, 187, 188, 189, 190, 191, 
+  225, 226, 247, 231, 228, 229, 246, 250, 233, 234, 235, 236, 237, 238, 239, 240, 
+  242, 243, 244, 245, 230, 232, 227, 254, 251, 253, 255, 249, 248, 252, 224, 241,
+  193, 194, 215, 199, 196, 197, 214, 218, 201, 202, 203, 204, 205, 206, 207, 208, 
+  210, 211, 212, 213, 198, 200, 195, 222, 219, 221, 223, 217, 216, 220, 192, 209 };
+
+
+// from, to
+void DoRecode(char *s, char *d){
+  unsigned char *s2=(unsigned char*)s, *d2=(unsigned char*)d;
+  while((*s2)!='\0'){
+    *(d2++)=recodetbl[unsigned(*(s2++))];
+  }
+  *d2='\0';
+}
+
 
 KDisplayText::KDisplayText(QWidget *parent,const char *name) : QScrollView(parent,name)
 {
@@ -255,6 +292,7 @@
 return start;
 };
 
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
 void KDisplayText::drawContents(QPainter *p, int /*clipx*/, int clipy, int /*clipw*/, int cliph)
 {
     p->setFont(*qtextfont);
@@ -293,11 +331,24 @@
                 p->setPen(black);
                 colorplayed=0;
             }	
-            
-            if (IsLineFeed(tmp->spev->text[0],tmp->spev->type))
-                p->drawText(tmp->xpos,tmpl->ypos,&tmp->spev->text[1]);
-            else
-                p->drawText(tmp->xpos,tmpl->ypos,tmp->spev->text);
+
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!            
+	    char *tbuf=new char[strlen(tmp->spev->text)+1]; /* KOI-8 Hack */
+	    DoRecode(tmp->spev->text, tbuf);	            /* KOI-8 Hack */
+	    
+            if (IsLineFeed(tmp->spev->text[0],tmp->spev->type)){
+	        /* KOI-8 Hack */
+                //p->drawText(tmp->xpos,tmpl->ypos,&tmp->spev->text[1]);
+                QString qtmp1=QString::fromLocal8Bit(tbuf+1);				
+		p->drawText(tmp->xpos,tmpl->ypos, qtmp1);
+            }else{
+	        /* KOI-8 Hack */
+	        //p->drawText(tmp->xpos,tmpl->ypos,tmp->spev->text);
+                QString qtmp2=QString::fromLocal8Bit(tbuf);				
+		p->drawText(tmp->xpos,tmpl->ypos, qtmp2);
+	    }		
+		
+            delete tbuf;		
 
 #ifdef DRAW_BOUNDING_RECTS
 	    p->setPen(red);
@@ -503,6 +554,9 @@
     calculatePositions();
     nvisiblelines=height()/qfmetr->lineSpacing();
     viewport()->repaint(TRUE);
+    
+    //!!!!!!!!!!!!!!1
+//    qtextfont->Script(QFont::Cyrillic);
 }
 
 void KDisplayText::ChangeTypeOfTextEvents(int type)
