Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: translate h...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 2219 of 2317
Post > Topic >>

Re: translate html codes to ascii chars

by spcecdt@[EMAIL PROTECTED] (John DuBois) Apr 9, 2008 at 01:36 PM

In article
<e7342bbc-7909-474f-ae75-18c0b272494c@[EMAIL PROTECTED]
>,
tomekl  <tomek@[EMAIL PROTECTED]
> wrote:
>I need to replace html codes with ascii chars, so for
>
>'&#73;&#74;aaaa&#75;'
>
>output should be:
>
>'IJaaaaK'

The following is inefficient, but should give you an idea of a general
approach
you could use to carry out this transformation.  It only deals with
numeric
code character entities, as in your example text.

echo "&#73;&#74;aaaa&#75;" | gawk '
{
    while (match($0,/&#[0-9]+;/))
	$0 = substr($0, 1, RSTART-1) sprintf("%c", substr($0, RSTART+2)+0) \
		substr($0, RSTART+RLENGTH)
    print
}'

	John
-- 
John DuBois  spcecdt@[EMAIL PROTECTED]
  KC6QKZ/AE 
http://www.armory.com/~spcecdt/
 




 6 Posts in Topic:
translate html codes to ascii chars
tomekl <tomek@[EMAIL P  2008-04-09 02:01:40 
Re: translate html codes to ascii chars
pk <pk@[EMAIL PROTECTE  2008-04-09 11:37:59 
Re: translate html codes to ascii chars
tomekl <tomek@[EMAIL P  2008-04-09 02:45:41 
Re: translate html codes to ascii chars
pk <pk@[EMAIL PROTECTE  2008-04-09 12:23:53 
Re: translate html codes to ascii chars
spcecdt@[EMAIL PROTECTED]  2008-04-09 13:36:26 
Re: translate html codes to ascii chars
tomekl <tomek@[EMAIL P  2008-04-11 02:29:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 1:02:22 CDT 2008.