Displaying text files encoded in Unicode online
The problem
When displaying text files with a special extension and containing accented or foreign script characters in the browser,
the files are not displayed properly — unless they have the BOM indicator at the beginning of the file
(3 invisible bytes which will tell the browser to interpret the text correctly).
See this article on Wikipedia
Lilypond
The problem affects in particular the Lilypond files (extension ly)
and has been mentioned at
this page of the forum.
as accented characters or characters from other scripts are not displayed correctly.
Solution
Add these directives at one of these places:
AddCharset UTF-8 .ly
# Add MIME type for LilyPond files
AddType text/x-lilypond .ly
-
To the Apache configuration file (which I cannot do for this page,
published on the shared webhosting at Infamaniak) - see reference there at the bottom
-
To the
.htacess file at the root of the website.
The site for this page has been corrected as mentioned above
and Unicode non Ascii characters are diplays properly for the ly files
On this
page, an explanation about Apache MIME types
If you want Apache to recognize a new file extension and associate it
with a specific MIME type, use AddType. This is the
standard, non-overriding method.
| Goal |
AddType Example |
Notes |
Serve .less files as CSS |
AddType text/css .less |
Apache will now treat all files ending in .less as
CSS. This is generally preferred over ForceType. |