You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Geraldo Netto <ge...@gmail.com> on 2015/06/25 20:21:25 UTC

[lang] StringEscapeUtils - from € to €

Dear All,

Sorry for cross-posting between user/dev lists
I'm trying to escape special chars using StringEscapeUtils

And i would like to ask
how can i change the escape format from html string code to html number code

So:
StringEscapeUtils.escapeHtml4(EURO_SIGN) is returning &euro;

But i would like to return: &#8364;

Do you have any suggestions on how to handle this?
In any case i'm willing to volunteer myself to write the code as long
as a mentor shows up :)


Thank You Very Much and Kind Regards,

Geraldo Netto
Sapere Aude => Non dvcor, dvco
São Paulo, Brasil, -3gmt
site: http://exdev.sf.net/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [lang] StringEscapeUtils - from € to €

Posted by Geraldo Netto <ge...@gmail.com>.
Hi Paulo! :)

Como vai?
(I suppose you are brazilian as me based on your name :P)

Thank you very much Sir for your suggestions :)
I'll try it!


Kind Regards,

Geraldo Netto
Sapere Aude => Non dvcor, dvco
São Paulo, Brasil, -3gmt
site: http://exdev.sf.net/

On 25 June 2015 at 19:33, Paulo Roberto Massa Cereda
<ce...@gmail.com> wrote:
> Hello, Geraldo. :)
>
> I once had to achieve something similar, so I created a new
> CharSequenceTranslator aggregating my own lookup table and the original
> arrays of entities. I had something along these lines:
>
> -------------------------------
> private static final CharSequenceTranslator HTML4_EURO
>             = new AggregateTranslator(
>                     new LookupTranslator(new String[][]{
>                         {"€", "&#8364;"}
>                     }),
>                     new LookupTranslator(
>                             EntityArrays.BASIC_ESCAPE()
>                     ),
>                     new LookupTranslator(
>                             EntityArrays.ISO8859_1_ESCAPE()
>                     ),
>                     new LookupTranslator(
>                             EntityArrays.HTML40_EXTENDED_ESCAPE()
>                     )
>             );
>
> ...
>
> // later on
>
> String str = HTML4_EURO.translate("áéíóú €");
>
> // should print &aacute;&eacute;&iacute;&oacute;&uacute; &#8364;
> System.out.println(str);
> -------------------------------
>
> Hope it helps. :)
>
> All the best,
>
> Paulo
>
>
> On 25-06-2015 15:21, Geraldo Netto wrote:
>>
>> Dear All,
>>
>> Sorry for cross-posting between user/dev lists
>> I'm trying to escape special chars using StringEscapeUtils
>>
>> And i would like to ask
>> how can i change the escape format from html string code to html number
>> code
>>
>> So:
>> StringEscapeUtils.escapeHtml4(EURO_SIGN) is returning &euro;
>>
>> But i would like to return: &#8364;
>>
>> Do you have any suggestions on how to handle this?
>> In any case i'm willing to volunteer myself to write the code as long
>> as a mentor shows up :)
>>
>>
>> Thank You Very Much and Kind Regards,
>>
>> Geraldo Netto
>> Sapere Aude => Non dvcor, dvco
>> São Paulo, Brasil, -3gmt
>> site: http://exdev.sf.net/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [lang] StringEscapeUtils - from € to €

Posted by Paulo Roberto Massa Cereda <ce...@gmail.com>.
Hello, Geraldo. :)

I once had to achieve something similar, so I created a new 
CharSequenceTranslator aggregating my own lookup table and the original 
arrays of entities. I had something along these lines:

-------------------------------
private static final CharSequenceTranslator HTML4_EURO
             = new AggregateTranslator(
                     new LookupTranslator(new String[][]{
                         {"€", "&#8364;"}
                     }),
                     new LookupTranslator(
                             EntityArrays.BASIC_ESCAPE()
                     ),
                     new LookupTranslator(
                             EntityArrays.ISO8859_1_ESCAPE()
                     ),
                     new LookupTranslator(
                             EntityArrays.HTML40_EXTENDED_ESCAPE()
                     )
             );

...

// later on

String str = HTML4_EURO.translate("áéíóú €");

// should print &aacute;&eacute;&iacute;&oacute;&uacute; &#8364;
System.out.println(str);
-------------------------------

Hope it helps. :)

All the best,

Paulo

On 25-06-2015 15:21, Geraldo Netto wrote:
> Dear All,
>
> Sorry for cross-posting between user/dev lists
> I'm trying to escape special chars using StringEscapeUtils
>
> And i would like to ask
> how can i change the escape format from html string code to html number code
>
> So:
> StringEscapeUtils.escapeHtml4(EURO_SIGN) is returning &euro;
>
> But i would like to return: &#8364;
>
> Do you have any suggestions on how to handle this?
> In any case i'm willing to volunteer myself to write the code as long
> as a mentor shows up :)
>
>
> Thank You Very Much and Kind Regards,
>
> Geraldo Netto
> Sapere Aude => Non dvcor, dvco
> São Paulo, Brasil, -3gmt
> site: http://exdev.sf.net/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org