]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/general-scheme.cc
Pass a list of design sizes into add-music-fonts function.
[lilypond.git] / lily / general-scheme.cc
index 1b3d531e1a304d590c9cb917720438ec439dbd99..cd7e25d8c055f052392a6d40a793c5b24bef7a06 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1998--2009 Jan Nieuwenhuizen <janneke@gnu.org>
+  Copyright (C) 1998--2010 Jan Nieuwenhuizen <janneke@gnu.org>
   Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
@@ -224,6 +224,58 @@ LY_DEFINE (ly_string_substitute, "ly:string-substitute",
   return ly_string2scm (ss);
 }
 
+bool
+is_not_escape_character (Byte c)
+{
+  switch (c)
+    {
+    case '-':
+    case '.':
+    case '/':
+    case '0'...'9':
+    case ':':
+    case 'A'...'Z':
+    case '_':
+    case 'a'...'z':
+      return true;
+    }
+
+  return false;
+}
+
+LY_DEFINE (ly_string_percent_encode, "ly:string-percent-encode",
+          1, 0, 0, (SCM str),
+          "Encode all characters in string @var{str} with hexadecimal"
+          " percent escape sequences, with the following exceptions:"
+          " characters @code{-}, @code{.}, @code{/}, and @code{_}; and"
+          " characters in ranges @code{0-9}, @code{A-Z}, and @code{a-z}.")
+{
+  LY_ASSERT_TYPE (scm_is_string, str, 1);
+
+  string orig_str = ly_scm2string (str);
+  string new_str = "";
+
+  vsize i = 0;
+  vsize n = orig_str.size ();
+
+  while (i < n)
+    {
+      Byte cur = orig_str[i];
+
+      if (is_not_escape_character (cur))
+       new_str += cur;
+      else
+       {
+         new_str += '%';
+         new_str += String_convert::bin2hex (cur);
+       }
+
+      i++;
+    }
+
+  return ly_string2scm (new_str);
+}
+
 LY_DEFINE (ly_number_2_string, "ly:number->string",
           1, 0, 0, (SCM s),
           "Convert @var{num} to a string without generating many decimals.")