Re: Encoding Issue for .ly Files on CPDL
Hans Aikema <[email protected]>
| Newsgroups | gmane.comp.gnu.lilypond.general |
|---|---|
| Message-ID | <[email protected]> |
> On 2 Jun 2026, at 18:17, Silvain Dupertuis <[email protected]> wrote: > > Hello everyone. > There is an explanation of this page <https://ubiq.co/tech-blog/how-to-set-default-charset-to-utf-8-encoding-in-apache-using-htaccess/> > I tried this locally... with no success so far. > > [….] > On 2 Jun 2026, at 17:36, Silvain Dupertuis <[email protected]> wrote: > > I have checked this website. > It displays Unicode correctly in web pages. > But it does not display Unicode on text files > > These two exemple files contain a accented character > Tra me così dicendo (i grave) > Copyright © 2026 by CPDL (copyright sign) > If one download the file instead of opening it, the characters are correct. > But not when displayed as text. > > It is indeed quite a general problem (not limited to this particular website), due to the way text files are displayed in browsers) > > I do not know how to correct this at the level or the websiste. > > I have tested locally how text files are displayed, ans I have the same result... (using Firefox on Linux Ubuntu). > > One work-around is to correct the text files by adding the byte-order mark (BOM) <https://en.wikipedia.org/wiki/Byte_order_mark> > (it adds 3 bytes at the beginning of the file which indicates that the file is to be read in UTF-8 format (and in which ordre to read the groups of 2 bytes). This is quite easy and fast to do if one knows how, and does not affect the use of the file by Lilypond. > > Here is a test page with one of these files <https://silvain-dupertuis.org/test/lilypond/displaying-text-files.html> - the original and the one with the BOM added, where one can see that this solves the problem. And it seems important to correct the problem, especially when it come to lyrics and any other language than English... > > Your test server sends the file as "content-type: text/x-lilypond”, without a character-encoding, which means it leaves it up to the browser to decide, which will then (on my browser - Firefox on Mac OS) falls back to a very generic encoding…. US-ASCII To render as UTF-8 it should send content-type: text/x-lilypond;charset=utf-8 So the big question is…. what did you configure locally on your side I would expect 8><8><8><8>< <filesMatch "\.(html|css|js|txt|php|ly)$"> AddDefaultCharset UTF-8 DefaultLanguage en-US </filesMatch> 8><8><8><8>< or 8><8><8><8>< AddCharset utf-8 .html .css .php .txt .js .ly 8><8><8><8>< to do the trick (note the added .ly there, which is needed to make the clause apply to .ly files)