From: Heesob Park Date: 2008-05-30T17:01:27+09:00 Subject: Re: how to generate ascii code? Hi, 2008/5/30 dare ruby : > 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 L or ÿ is given i need > to convert those into corresponding ascii. consider character reference > like L 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: WEL after ASCII code conversion it should be WELCOME as > for 76 corresponding ascii value is 'L'. > > Like wise consider the second example ÿ > > 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("WELCOME") => "WELCOME" irb(main):003:0> CGI.unescapeHTML("WEÿCOME") => "WE\377COME" Regards, Park Heesob