CVSROOT: /cvsroot/lilypond
Module name: lilypond
Branch:
Changes by: Han-Wen Nienhuys <[EMAIL PROTECTED]> 05/05/09 09:19:52
Modified files:
. : ChangeLog
lily : general-scheme.cc
Log message:
(LY_DEFINE): hand-convert utf8 to 32
bits. Patch by Matthias Neeracher.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3576&tr2=1.3577&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/general-scheme.cc.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3576 lilypond/ChangeLog:1.3577
--- lilypond/ChangeLog:1.3576 Mon May 9 08:41:15 2005
+++ lilypond/ChangeLog Mon May 9 09:19:51 2005
@@ -1,3 +1,8 @@
+2005-05-09 Han-Wen Nienhuys <[EMAIL PROTECTED]>
+
+ * lily/general-scheme.cc (LY_DEFINE): hand-convert utf8 to 32
+ bits. Patch by Matthias Neeracher.
+
2005-05-09 Mats Bengtsson <[EMAIL PROTECTED]>
* scripts/convert-ly.py: In the conversion to version 1.9.0,
Index: lilypond/lily/general-scheme.cc
diff -u lilypond/lily/general-scheme.cc:1.18
lilypond/lily/general-scheme.cc:1.19
--- lilypond/lily/general-scheme.cc:1.18 Mon May 2 12:39:28 2005
+++ lilypond/lily/general-scheme.cc Mon May 9 09:19:52 2005
@@ -12,11 +12,6 @@
#include <math.h> /* isinf */
#include <stdio.h>
#include <string.h> /* memset */
-#if HAVE_UTF8_WCHAR_H
-#include <utf8/wchar.h> /* wcrtomb */
-#else
-#include <wchar.h> /* wcrtomb */
-#endif
#include "international.hh"
#include "libc-extension.hh"
@@ -249,17 +244,29 @@
1, 0, 0, (SCM wc),
"Encode the Unicode codepoint @var{wc} as UTF-8")
{
- char buf[100];
+ char buf[5];
SCM_ASSERT_TYPE (scm_is_integer (wc), wc, SCM_ARG1, __FUNCTION__, "integer");
- wchar_t wide_char = (wchar_t) scm_to_int (wc);
+ unsigned wide_char = (unsigned) scm_to_int (wc);
+ char * p = buf;
- mbstate_t state;
- memset (&state, '\0', sizeof (state));
- memset (buf, '\0', sizeof (buf));
+ if (wide_char < 0x0080) {
+ *p++ = (char)wide_char;
+ } else if (wide_char < 0x0800) {
+ *p++ = (char)(((wide_char >> 6) ) | 0xC0);
+ *p++ = (char)(((wide_char ) & 0x3F) | 0x80);
+ } else if (wide_char < 0x10000) {
+ *p++ = (char)(((wide_char >> 12) ) | 0xE0);
+ *p++ = (char)(((wide_char >> 6) & 0x3F) | 0x80);
+ *p++ = (char)(((wide_char ) & 0x3F) | 0x80);
+ } else {
+ *p++ = (char)(((wide_char >> 18) ) | 0xF0);
+ *p++ = (char)(((wide_char >> 12) & 0x3F) | 0x80);
+ *p++ = (char)(((wide_char >> 6) & 0x3F) | 0x80);
+ *p++ = (char)(((wide_char ) & 0x3F) | 0x80);
+ }
+ *p = 0;
- wcrtomb (buf, wide_char, &state);
-
return scm_makfrom0str (buf);
}
_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs