Why not just use the yaws "--erlarg" option to pass +fnu to erl?

yaws --erlarg +fnu

--steve

On Wed, Mar 6, 2013 at 12:55 PM, Arif <arif@riseup.net> wrote:
I'm using erlang 15B03 and yaws 1.95

My application communicates file names in a local directory to a browser using a websocket.

The names are passed to the browser in a json data structure as an array. I construct that array from the list of file names by means of io_lib:format using the ~p format specifier and not using any particular library.

handle_message({text, _Request}) ->
    {ok, Files} = file:list_dir(SomeDirectory),
    Reply = io_lib:format("{\"files\": ~p}", [Files]),
    {reply, list_to_binary(Reply)}.

The fact is that when the file name contains unicode characters, file:list_dir/1 gives me the file name as a list of bytes that javascript (in the browser) cannot read as a string straight away. Also, I log the file names using the error_logger and such file names get logged as a list of numbers and not as strings.

It's not a big deal. I can force javascript to read the byte list with a toString() function and I can use the io module to render the byte list as a unicode string in the error_logger info_report, but it would be simple to avoid it if I could pass the +fnu flag to erl when it runs the yaws application, very much like +pa.

Thanks and best regards
Arif


On 03/06/2013 01:25 PM, Steve Vinoski wrote:


On Tue, Mar 5, 2013 at 2:49 PM, Arif <arif@riseup.net> wrote:
Hi,

I need to manipulate utf-8 file names in my appmod (on a linux machine).

I know I can give the +fnu parameter to erl to get functions like
file:list_dir/1 to honour file names in utf-8, but how do I get yaws to
do the same?

I've done work in the past with utf-8 and yaws and don't recall having any trouble with it. Can you send along a test case that shows what problem you're running into? Also, please let us know what versions of Erlang and yaws you're using.

--steve