summaryrefslogtreecommitdiffstats
path: root/mandriva/2010.2/kdebase/turkish-preview.patch
blob: 1b0249798675c5c6e2a62a9471bb5a2935b750f5 (plain)
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
Index: kioslave/thumbnail/textcreator.cpp
===================================================================
--- kioslave/thumbnail/textcreator.cpp	(revision 664853)
+++ kioslave/thumbnail/textcreator.cpp	(working copy)
@@ -25,6 +25,7 @@
 #include <kstandarddirs.h>
 #include <kpixmapsplitter.h>
 #include <kmimetype.h>
+#include <qtextcodec.h>
 
 #include "textcreator.h"
 
@@ -112,11 +113,48 @@
         int read = file.readBlock( m_data, bytesToRead );
         if ( read > 0 )
         {
-            ok = true;
             m_data[read] = '\0';
+            ok = false;
+            uint total=1000;
+
+            if (read < total) total = read;
+
+            for (uint i = 0; i < total - 1; i++)
+              {
+                switch (m_data[i]) {
+                case 195:
+                  if ((m_data[i+1] == -74) || (m_data[i+1] == -89) ||
+                      (m_data[i+1] == -68) || (m_data[i+1] == -106) ||
+                      (m_data[i+1] == -121) || (m_data[i+1] == -100)) {
+                    ok = true;
+                    break;
+                  }
+                case 196:
+                  if ((m_data[i+1] == -79) || (m_data[i+1] == -97) ||
+                      (m_data[i+1] == -80) || (m_data[i+1] == -98)) {
+                    ok = true;
+                    break;
+                  }
+
+                case 197:
+                  if ((m_data[i+1] == -97) || (m_data[i+1] == -98)) {
+                    ok = true;
+                    break;
+                  }
+                }
+                if (ok) break;
+              }
+            /* Finish of Encoding herustic. */
             TQString text = TQString::fromLocal8Bit( m_data );
+            if (!ok)
+              {
+                TQTextCodec *codec = TQTextCodec::codecForName("ISO8859-9");
+                text = codec->toUnicode( m_data );
+              }
+            //						TQString text = TQString::fromUtf8( m_data );
             // FIXME: maybe strip whitespace and read more?
 
+            ok = true;
             m_pixmap.fill( TQColor( 245, 245, 245 ) ); // light-grey background
 
             TQRect rect;
@@ -171,6 +209,49 @@
                     continue;
                 }
 
+                // Turkish Conversions Begin
+
+                switch (ch.unicode()) {
+                case 305:
+                  ch = 224; // ı
+                  break;
+                case 351:
+                  ch = 229; // ş
+                  break;
+                case 246:
+                  ch = 227; // ö
+                  break;
+                case 231:
+                  ch = 228; // ç
+                  break;
+                case 252:
+                  ch = 226; // ü
+                  break;
+                case 287:
+                  ch = 225; // ğ
+                  break;
+                case 304:
+                  ch = 230; // İ
+                  break;
+                case 214:
+                  ch = 232; // Ö
+                  break;
+                case 199:
+                  ch = 233; // Ç
+                  break;
+                case 286:
+                  ch = 231; // Ğ
+                  break;
+                case 220:
+                  ch = 235; // Ü
+                  break;
+                case 350:
+                  ch = 234; // Ş
+                  break;
+                }
+
+                // Turkish Conversions End
+
                 rect = m_splitter->coordinates( ch );
                 if ( !rect.isEmpty() )
                 {