Reading and writing non-ascii filenames with Livecode Server under Linux
This lessons describes 2 methods how to enable Livecode Server to write/read files with non-ascii filenames under Linux.
According to the configuration of your server it could be that Livecode Server is not able to read/write files with non-ascii filenames.
For example running this script
put the seconds into URL "file:testä.txt" put the result
would return can't open file on such Apache servers.
This method uses a redirect rule in .htaccess to set the environment variable LANG.
To get this working your Apache server needs to have the mod_rewrite modul enabled. Most hosting providers have this modul enabled by default.
If not you could ask your provider to enable this module.
If you run your own server make sure that the mod_rewrite modul is enabled in your httpd.conf file.
In that file you should find a line
#LoadModule rewrite_module modules/mod_rewrite.s
Remove the # from the line and restart Apache to get the new configuration loaded.
Open the .htaccess file in an editor and search for a line RewriteEngine On
and add the following line below that line
RewriteRule \.(lc) - [E=LANG:en_US.UTF-8]
If there is no line RewriteEngine On, then add the following 2 lines to the .htaccess file
RewriteEngine On RewriteRule \.(lc) - [E=LANG:en_US.UTF-8]
After saving the .htaccess file you should be able to read and save files with non-ascii filenames.
The RewriteRule tells Apache to set the environment variable LANG to en_US.UTF-8 every time an .lc file is executed/accessed.
The new value of LANG is only used for that session in which the livecode server script is executed. So there is no risk to harm any other apps on the server.
This method was posted to the mailing-list by Mark Waddingham
This method makes i mandatory that Livecode Server is already installed and the httpd.conf is correctly configured for Livecode Server
If you do not already have setup your server to use Livecode Server then please see the following lesson on how to install Livecode Server on Linux
You need to have write access to the httpd.conf file of your Apache server to use this method.
create a text file with the following content
#!/bin/sh export LC_ALL="en_US.UTF-8" export LANG="en_US.UTF-8" exec livecode-server
Save the file in the same folder where also Livecode Server executable is located.
Open the httpd.conf file and search for the line
ScriptAlias /livecode-cgi/livecode-server "<path to LiveCode Server folder>/livecode-server"
where "<path to LiveCode Server folder>/livecode-server" is the path to your Livecode Server executable.
Now replace the path to the Livecode Server executable with the path to your created shell script
Let's say Livecode Server was installed in /home/ua123456/public_html/cgi-bin/livecode-server/ and we named the shell script myLCSstarter
then the original line would like this
ScriptAlias /livecode-cgi/livecode-server /home/ua123456/public_html/cgi-bin/livecode-server/livecode-server
and after replacing the line would look like this
ScriptAlias /livecode-cgi/livecode-server /home/ua123456/public_html/cgi-bin/livecode-server/myLCSstarter
Save the httpd.conf and restart Apache.
After that you should be able to write and read files with non-ascii file names.