Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Feb 2005 11:11:15 +0000
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Anthony Atkielski <atkielski.anthony@wanadoo.fr>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Another grep question
Message-ID:  <20050208111115.GA75417@gravitas.thebunker.net>
In-Reply-To: <757352437.20050208034447@wanadoo.fr>
References:  <1667502496.20050208025619@wanadoo.fr> <D9FB5D8199759D4D997460C5C0A1C11C013285BE@exch-dc2.bytemobile.com> <757352437.20050208034447@wanadoo.fr>

next in thread | previous in thread | raw e-mail | index | archive | help

--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Feb 08, 2005 at 03:44:47AM +0100, Anthony Atkielski wrote:
> Giorgos Keramidas writes:
>=20
> GK> It may not be related to what you are seeing, but grep(1)
> GK> is locale-aware.  What it considers a "text" character
> GK> depends on the current locale settings.
>=20
> I tried setting LC_ALL to en_US.UTF-8, en_US.ISO8859-15, and
> en_US.ISO8859-1, with no effect.  The character in question is an
> opening double quotation mark in the Windows character set.  I want to
> find it in my Web pages and replace it by an appropriate HTML escape
> sequence.  I know it's out there, but grep isn't finding it, or I'm not
> telling it how to find the character correctly.

Ah -- well, the beauty of Unix is that if the first tool you think of
doesn't do the job, then the next one probably will.

You can use perl to match and replace arbitrary characters:

    % perl -pi.bak -e 's/\x93/&ldquo;/g' foo.html

Or you could go for the bulk method and run HTML tidy(1) over the
file, which is usually pretty good at converting any-old HTML into
something that will pass validation:

    (ports: www/tidy)       http://www.w3c.org/People/Raggett/tidy/
    (ports: www/tidy-devel) http://tidy.sourceforge.net/

    Cheers,

    Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       8 Dane Court Manor
                                                      School Rd
PGP: http://www.infracaninophile.co.uk/pgpkey         Tilmanstone
Tel: +44 1304 617253                                  Kent, CT14 0JL UK

--cWoXeonUoKmBZSoM
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)

iQCVAwUBQgieU5r7OpndfbmCAQK++AP/SMIzrkTJ1+iETTW7G5meSYVGiHoifn8C
AYboigg5D+1iWzD6mKAQiQ4AZF4sjdIBXrWI1997q5p+SnSb3Ulq3IVM8KQ9Iqts
l1e0qWKMozF4wmuWe40wOMNzFKJ63fveSRFxKpSb0bfuqN8Jqkjx0ApaI1MetG9t
cNeb6yMd+cw=
=NLio
-----END PGP SIGNATURE-----

--cWoXeonUoKmBZSoM--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050208111115.GA75417>