lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unicode chars in scheme?


From: Mark Polesky
Subject: Re: Unicode chars in scheme?
Date: Wed, 24 Jun 2009 09:26:37 -0700 (PDT)

Tao Cumplido wrote:
> Unfortunately I still get errors. There seems to be a problem of
> the scheme way to encode unicode and the lilypond way.
> The following gives me errors and no text output:
>
> tf =
> #(define-music-function (parser location music) (ly:music?)
>   (let* ((es (ly:music-property music 'elements)))
>     (ly:music-set-property! (car (cdr es)) 'text
>       (string (integer->char #x00a9)))) music)
> <<
>     \override Score.TextScript #'font-name = #"JazzChords"
>     \tf c'1-"text"
> >>
>
> If I replace (string (integer->char #x00a9)) with "©" it works
> fine. So, for console output the integer->char conversion works
> fine but it gives errors when applying to Lilypond output.
>
> Actually (display "©") gives the following console output -> ©
>
> If I now change the above to the following:
> (string (integer->char #x00c2) (integer->char #x00a9))
>
> i.e. a string composed of the charracters  and ©
> This way I get the desired output and just © is displayed in the
> lilypond output.
>
> Any idea why this happens and how to solve it?

Tao,

it looks to me like you've solved it already?
Why not use this for your music-function:

tf =
#(define-music-function (parser location music) (ly:music?)
  (let* ((es (ly:music-property music 'elements)))
    (ly:music-set-property! (car (cdr es)) 'text "©")) music)

and use this for the console:

(define (display-unicode x)
  (display (integer->char x)))

(display-unicode #xa9)

(for-each display-unicode
  (list #x66 #x6f #x6f #x62 #x61 #x72 #xa9))

Perhaps I'm not understanding the remaining issue to be solved if
there is one. Clear me up if that's the case.

Regarding the extra  character... this kind of thing happens all
the time on the web, and it is very frustrating, but I forget the
precise cause. My guess is that it has something to do with the
encoding conversion between UTF-8 and ISO-8859-1 or Windows-1252...
http://en.wikipedia.org/wiki/ISO-8859-1#ISO-8859-1_and_Windows-1252_confusion
...but I'm not able to precisely identify the problem, and I don't
think the code point in question here (00a9) is in the affected
range.

I'm curious to know what the console displays with (display "©")
on Mac/Linux. Perhaps it's a Windows issue. If so, then we could
add a "Windows gotcha" note in the docs.

Can a Mac/Linux user compile this minimal .ly file:

#(display "©")

and report on the console display?

Thanks.
- Mark








reply via email to

[Prev in Thread] Current Thread [Next in Thread]