lilypond-user
[Top][All Lists]
Advanced

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

Re: UTF-8-aware backwards string searching in Guile, or: fixing centered


From: Aaron Hill
Subject: Re: UTF-8-aware backwards string searching in Guile, or: fixing centered lyrics ignoring punctuation
Date: Tue, 30 Oct 2018 21:23:12 -0700
User-agent: Roundcube Webmail/1.3.6

On 2018-10-30 4:56 pm, Aaron Hill wrote:
On 2018-10-30 10:01 am, Alexander Kobel wrote:
Does anyone have a hint how to approach this one? (Or is the answer
just: be patient and hope for Guile v2?)

The only hint here is to replace the built-in functions with ones
which understand UTF8 encoding and can perform the work needed.  There
very well might be someone online who has already done this work,
which would save on having to do it yourself.

Otherwise, the basic strategy is to replace string->list with a
version that decodes UTF8 and returns a list of integers (essentially
UTF32).  Then, all of the string work is being done with these lists
of integers instead.  (The character set would also just be a set of
integers representing the unique Unicode code points.)  After you find
the subsets of the list that are interesting to measure, you'll then
need to convert the list back into a string.  This means encoding back
into UTF8 and emitting a string.

Here's a quick-n-dirty patch to address the issue.

%%%%
\version "2.19.82"
\include "center-lyrics-ignoring-punctuation.ily"
{ d'4 4 4 }
\addlyrics { Å Ɓ† «Ḉ…» }
%%%%

-- Aaron Hill

Attachment: center-lyrics-ignoring-punctuation.ily
Description: Text document

Attachment: utf8.cropped.png
Description: PNG image


reply via email to

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