Hi,

2008/5/30 dare ruby <martin / angleritech.com>:
> Dear all,
>
> Iam in process of building a parser. I need to convert the numeric
> character reference to corresponding ascii.
>
> when numeric character reference like &#76; or &#x00ff; is given i need
> to convert those into corresponding ascii. consider character reference
> like &#76; my parser will read character by character and eliminate &#;
> and store '76' alone in a string variable (temp), so now temp = '76', i
> need to generate its corresponding ascii value 'L'. please help me to
> the process
>
>  example: WE&#76; after ASCII code conversion it should be WELCOME as
> for 76 corresponding ascii value is 'L'.
>
>  Like wise consider the second example &#x00ff;
>
>   now temp = 00ff it should also generate its corresponding ascii code.
>
>   in both cases even if its a decimal value or hexa decimal value its
> is stored as string in my process. As iam reading character by character
> from buffer and adding each character to temp string.
>
> so please help me to solve this issue..
>
> Thanks in advance...
>

irb(main):001:0> require 'cgi'
=> true
irb(main):002:0> CGI.unescapeHTML("WE&#76;COME")
=> "WELCOME"
irb(main):003:0> CGI.unescapeHTML("WE&#x00ff;COME")
=> "WE\377COME"


Regards,

Park Heesob