source file of the GNU LilyPond music typesetter
- (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "config.hh"
-#include <math.h> /* isinf */
+#include <libintl.h> /* gettext on MacOS X */
+#include <math.h> /* isinf */
#include <stdio.h>
-#include <libintl.h> // gettext on macos x
+#include <string.h> /* memset */
+#include <wchar.h> /* wcrtomb */
#include "libc-extension.hh"
#include "lily-guile.hh"
#endif
+/*
+ Ugh. Gulped file is copied twice. (maybe thrice if you count stdio
+ buffering.)
+ */
LY_DEFINE (ly_gulp_file, "ly:gulp-file",
1, 0, 0, (SCM name),
"Read the file @var{name}, and return its contents in a string. "
return default_value;
}
-
LY_DEFINE (ly_number2string, "ly:number->string",
1, 0, 0, (SCM s),
"Convert @var{num} to a string without generating many decimals.")
return scm_makfrom0str (str);
}
-
-
-LY_DEFINE (ly_version, "ly:version", 0, 0, 0, (),
+LY_DEFINE (ly_version, "ly:version", 0, 0, 0, (),
"Return the current lilypond version as a list, e.g. @code{(1 3 127 uu1)}. ")
{
char const* vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")" ;
return scm_c_eval_string ((char*)vs);
}
-LY_DEFINE (ly_unit, "ly:unit", 0, 0, 0, (),
+LY_DEFINE (ly_unit, "ly:unit", 0, 0, 0, (),
"Return the unit used for lengths as a string.")
{
return scm_makfrom0str (INTERNAL_UNIT);
}
-
-
-LY_DEFINE (ly_dimension_p, "ly:dimension?", 1, 0, 0, (SCM d),
+LY_DEFINE (ly_dimension_p, "ly:dimension?", 1, 0, 0, (SCM d),
"Return @var{d} is a number. Used to distinguish length "
"variables from normal numbers.")
{
{
SCM_ASSERT_TYPE (scm_is_string (string), string, SCM_ARG1,
__FUNCTION__, "string");
- return scm_makfrom0str (gettext (scm_i_string_chars (string)));
+ return scm_makfrom0str (_ (scm_i_string_chars (string)).to_str0 ());
}
-
-
-
LY_DEFINE (ly_output_backend, "ly:output-backend",
0, 0, 0, (),
"Return name of output backend.")
return scm_makfrom0str (output_backend_global.to_str0 ());
}
-
LY_DEFINE (ly_output_formats, "ly:output-formats",
0, 0, 0, (),
"Formats passed to --format as a list of strings, "
return lst;
}
+
+LY_DEFINE (ly_wchar_to_utf_8, "ly:wide-char->utf-8",
+ 1, 0, 0, (SCM wc),
+ "Encode the Unicode codepoint @var{wc} as UTF-8")
+{
+ char buf[100];
+
+ SCM_ASSERT_TYPE (scm_is_integer (wc), wc, SCM_ARG1, __FUNCTION__, "integer");
+ wchar_t wide_char = (wchar_t) scm_to_int (wc);
+
+ mbstate_t state;
+ memset (&state, '\0', sizeof (state));
+ memset (buf, '\0', sizeof (buf));
+
+ wcrtomb (buf, wide_char, &state);
+
+ return scm_makfrom0str (buf);
+}
+