I've been meaning to post this to the list for a while... I hope it will
be useful to someone.

Erlang Web 1.2.1 is mostly Unicode-clean, in the sense that if you put
in correct UTF-8 at one end, you get the same correct UTF-8 at the other
end.  Unfortunately, this doesn't apply to wpart:lookup - the output
will look like if the input was treated as Latin-1 instead of UTF-8,
though the actual truth is more complicated than that.

Therefore I've been using the attached wpart:lookup_unbreak, which has
the same interface as wpart:lookup, except that it doesn't use the
'format' attribute.

EEP 10 (http://erlang.org/eeps/eep-0010.html) promises a consistent
Unicode representation for Erlang, and it is fully implemented in OTP
R13 (now in beta), but still usable in older Erlang versions.  From my
understanding, Erlang Web 1.3 will thus remove the need for ugly hacks
like mine :)

BTW, this mailing list can be read on Gmane nowadays:
http://dir.gmane.org/gmane.comp.lang.erlang.erlangweb.general

%% @doc Wpart similar to <code>wpart:lookup</code>, except that it
%% only works for strings, and takes care not to double-encode UTF-8
%% data.  This will eventually be fixed in <code>wpart:lookup</code>…
-module(wpart_lookup_unbreak).

-export([handle_call/1]).
-behaviour(wpart).

-include_lib("xmerl/include/xmerl.hrl").

handle_call(#xmlElement{} = E) ->
    Key = wpartlib:has_attribute("attribute::key", E),
    case wpart:fget(Key) of
        undefined ->
            "";
        Value ->
            #xmlText{type = cdata,
                     value = wtype_html:htmlize(Value)}
    end.

-- 
Magnus Henoch, mag...@erlang-consulting.com
Erlang Training and Consulting
http://www.erlang-consulting.com/
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Erlangweb-users mailing list
Erlangweb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlangweb-users
http://www.erlang-web.org/

Reply via email to