Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Unescape HTML text
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Zabrane Mickael  
View profile  
 More options Sep 25 2012, 2:02 pm
From: Zabrane Mickael <zabra...@gmail.com>
Date: Tue, 25 Sep 2012 20:02:06 +0200
Local: Tues, Sep 25 2012 2:02 pm
Subject: [erlang-questions] Unescape HTML text

Hi huis,

I want  to convert an HTML escaped text (http://www.w3schools.com/tags/ref_entities.asp) like this one:

bourg&eacute; Cop

to:

bourgé Cop

Is there any Erlang library for this?

Regards,
Zabrane

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zabrane Mickael  
View profile   Translate to Translated (View Original)
 More options Sep 25 2012, 2:49 pm
From: Zabrane Mickael <zabra...@gmail.com>
Date: Tue, 25 Sep 2012 20:48:15 +0200
Local: Tues, Sep 25 2012 2:48 pm
Subject: Re: [erlang-questions] Unescape HTML text

answering my own question:

unescape(<<>>) ->
    <<>>;
unescape([]) ->
    <<>>;
unescape(L) when is_list(L) ->
    unescape(list_to_binary(L));
unescape(B) when is_binary(B) ->
    unescape(B, <<>>).

unescape(<<>>, Acc) ->
    Acc;
unescape(<<"&nbsp;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, " ">>);
unescape(<<"&amp;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "&">>);
unescape(<<"&quot;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "\"">>);
unescape(<<"&apos;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "\'">>);
unescape(<<"&#39;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "'">>);
unescape(<<"&lt;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "<">>);
unescape(<<"&gt;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, ">">>);
unescape(<<"&euro;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "€">>);
unescape(<<"&ccedil;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "ç">>);
unescape(<<"&agrave;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "à">>);
unescape(<<"&acirc;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "â">>);
unescape(<<"&auml;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "ä">>);
unescape(<<"&aelig;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "æ">>);
unescape(<<"&egrave;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "è">>);
unescape(<<"&eacute;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "é">>);
unescape(<<"&ecirc;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "ê">>);
unescape(<<"&euml;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "ë">>);
unescape(<<"&icirc;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "î">>);
unescape(<<"&iuml;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "ï">>);
unescape(<<"&ouml;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "ö">>);
unescape(<<"&ugrave;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "ù">>);
unescape(<<"&uacute;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "ú">>);
unescape(<<"&ucirc;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "û">>);
unescape(<<"&uuml;", T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, "ü">>);

unescape(<<C, T/binary>>, Acc) ->
    unescape(T, <<Acc/binary, C>>).

Regards,
Zabrane

On Sep 25, 2012, at 8:02 PM, Zabrane Mickael wrote:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Ippolito  
View profile  
 More options Sep 25 2012, 3:31 pm
From: Bob Ippolito <b...@redivi.com>
Date: Tue, 25 Sep 2012 12:31:37 -0700
Local: Tues, Sep 25 2012 3:31 pm
Subject: Re: [erlang-questions] Unescape HTML text

That's a subset of possible inputs, you're better off using a library
that's a bit more complete. This may be useful:
https://github.com/mochi/mochiweb/blob/master/src/mochiweb_charref.erl

On Tue, Sep 25, 2012 at 11:48 AM, Zabrane Mickael <zabra...@gmail.com>wrote:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zabrane Mickael  
View profile  
 More options Sep 25 2012, 3:33 pm
From: Zabrane Mickael <zabra...@gmail.com>
Date: Tue, 25 Sep 2012 21:33:09 +0200
Local: Tues, Sep 25 2012 3:33 pm
Subject: Re: [erlang-questions] Unescape HTML text

Thanks Bob.
Exactly what I needed.

Regards,
Zabrane

On Sep 25, 2012, at 9:31 PM, Bob Ippolito wrote:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »