Am Sonntag, 25. Februar 2007 10:01 schrieb Georg Baum:
> Am Sonntag, 25. Februar 2007 03:52 schrieb Enrico Forestieri:
> > On Sat, Feb 24, 2007 at 07:00:42PM +0100, Jean-Marc Lasgouttes wrote:
> > 
> > > Bug 1247 is about recognizing properly letters in non-latin1 text.
> > > This is fixed on linux using 32bits wchar_t. However, on windows
> > > another strategy has to be found, as discussed here
> > > http://bugzilla.lyx.org/show_bug.cgi?id=1247
> > > 
> > > Enrico, Abdel, could you have a look?
> > 
> > I think that your idea of using Qt is the right one. When I run the
> 
> I think so, too. I am working on a fix.

Here is the patch, please test. It fixes bug 3270 for me (did not test 
1247), but I am still not able to input an é via dead keys if LANG=C.

I introduced a new C file, because I did not want to pull in qt stuff to 
the core via the header. I don't know yet if this is a performance problem 
or not.


Georg
Index: src/support/lstrings.C
===================================================================
--- src/support/lstrings.C	(Revision 17335)
+++ src/support/lstrings.C	(Arbeitskopie)
@@ -14,6 +14,7 @@
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 #include "support/convert.h"
+#include "support/qstring_helpers.h"
 
 #include "debug.h"
 
@@ -32,17 +33,6 @@
 #include <algorithm>
 #include <sstream>
 
-#ifdef LIBC_WCTYPE_USES_UCS4
-// We can use the libc ctype functions because we unset the LC_CTYPE
-// category of the current locale in gettext.C
-#include <wctype.h>
-#else
-// Steal some code from somewhere else, e.g. glib (look at gunicode.h)
-// The code that we currently use does not really work.
-#endif
-
-
-using lyx::docstring;
 
 using std::transform;
 using std::string;
@@ -321,38 +311,15 @@ char uppercase(char c)
 }
 
 
-// FIXME UNICODE
-// for lowercase() and uppercase() function below when wchar_t is not used:
-// 1) std::tolower() and std::toupper() are templates that
-// compile fine with char_type. With the test (c >= 256) we
-// do not trust these function to do the right thing with
-// unicode char.
-// 2) these functions use the current locale, which is wrong
-// if it is not latin1 based (latin1 is a subset of UCS4).
-
 char_type lowercase(char_type c)
 {
-#ifdef LIBC_WCTYPE_USES_UCS4
-	return towlower(c);
-#else
-	if (c >= 256)
-		return c;
-
-	return tolower(c);
-#endif
+	return qchar_to_ucs4(ucs4_to_qchar(c).toLower());
 }
 
 
 char_type uppercase(char_type c)
 {
-#ifdef LIBC_WCTYPE_USES_UCS4
-	return towupper(c);
-#else
-	if (c >= 256)
-		return c;
-
-	return toupper(c);
-#endif
+	return qchar_to_ucs4(ucs4_to_qchar(c).toUpper());
 }
 
 
Index: src/support/textutils.C
===================================================================
--- src/support/textutils.C	(Revision 0)
+++ src/support/textutils.C	(Revision 0)
@@ -0,0 +1,43 @@
+// -*- C++ -*-
+/**
+ * \file textutils.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Georg Baum
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+// FIXME: I can think of a better name for this file ...
+
+#include "support/textutils.h"
+#include "support/qstring_helpers.h"
+
+namespace lyx {
+
+bool isLetterChar(char_type c)
+{
+	return ucs4_to_qchar(c).isLetter();
+}
+
+
+bool isPrintable(char_type c)
+{
+	return ucs4_to_qchar(c).isPrint();
+}
+
+
+bool isPrintableNonspace(char_type c)
+{
+	QChar const qc = ucs4_to_qchar(c);
+	return qc.isPrint() && !qc.isSpace();
+}
+
+
+bool isDigit(char_type c)
+{
+	return ucs4_to_qchar(c).isDigit();
+}
+
+} // namespace lyx

Eigenschaftsänderungen: src/support/textutils.C
___________________________________________________________________
Name: svn:eol-style
   + native

Index: src/support/textutils.h
===================================================================
--- src/support/textutils.h	(Revision 17335)
+++ src/support/textutils.h	(Arbeitskopie)
@@ -17,15 +17,6 @@
 
 #include "support/types.h"
 
-#ifdef LIBC_WCTYPE_USES_UCS4
-// We can use the libc ctype functions because we unset the LC_CTYPE
-// category of the current locale in gettext.C
-#include <wctype.h>
-#else
-// Steal some code from somewhere else, e.g. glib (look at gunicode.h)
-// The code that we currently use does not really work.
-#endif
-
 
 namespace lyx {
 
@@ -36,61 +27,17 @@ bool isLineSeparatorChar(char_type c)
 	return c == ' ';
 }
 
-
 /// return true if a char is alphabetical (including accented chars)
-inline
-bool isLetterChar(char_type c)
-{
-#ifdef LIBC_WCTYPE_USES_UCS4
-	return iswalpha(c);
-#else
-	// FIXME UNICODE This is wrong!
-	return (c >= 'A' && c <= 'Z')
-		|| (c >= 'a' && c <= 'z')
-		|| (c >= 192 && c < 256); // in iso-8859-x these are accented chars
-#endif
-}
-
+bool isLetterChar(char_type c);
 
 /// return true if the char is printable
-inline
-bool isPrintable(char_type c)
-{
-#ifdef LIBC_WCTYPE_USES_UCS4
-	return iswprint(c);
-#else
-	// FIXME UNICODE This is wrong!
-	return (c & 127) >= ' ';
-#endif
-}
-
+bool isPrintable(char_type c);
 
 /// return true if the char is printable and not a space
-inline
-bool isPrintableNonspace(char_type c)
-{
-#ifdef LIBC_WCTYPE_USES_UCS4
-	return iswprint(c) && !iswspace(c);
-#else
-	// FIXME UNICODE This is wrong!
-	return (c & 127) > ' ';
-#endif
-}
-
+bool isPrintableNonspace(char_type c);
 
 /// return true if a unicode char is a digit.
-inline
-bool isDigit(char_type c)
-{
-#ifdef LIBC_WCTYPE_USES_UCS4
-	return iswdigit(c);
-#else
-	// FIXME UNICODE This is wrong!
-	return c >= '0' && c <= '9';
-#endif
-}
-
-
+bool isDigit(char_type c);
 
 } // namespace lyx
 
Index: src/support/Makefile.am
===================================================================
--- src/support/Makefile.am	(Revision 17335)
+++ src/support/Makefile.am	(Arbeitskopie)
@@ -78,6 +78,7 @@ libsupport_la_SOURCES = \
 	systemcall.C \
 	systemcall.h \
 	tempname.C \
+	textutils.C \
 	textutils.h \
 	translator.h \
 	types.h \
Index: development/scons/scons_manifest.py
===================================================================
--- development/scons/scons_manifest.py	(Revision 17335)
+++ development/scons/scons_manifest.py	(Arbeitskopie)
@@ -160,6 +160,7 @@ src_support_files = Split('''
     socktools.C
     systemcall.C
     tempname.C
+    textutils.C
     unicode.C
     unlink.C
     userinfo.C

Reply via email to