[XML-SIG] Re: Issues with Unicode type

Eric van der Vlist vdv@dyomedea.com
23 Sep 2002 23:31:42 +0200


On Mon, 2002-09-23 at 23:16, Uche Ogbuji wrote:

> >   yep, that simple,
>=20
> Oh, but then Python is so much simpler:
>=20
>    =20
> SP_PAT =3D re.compile(u"[\uD800-\uDBFF][\uDC00-\uDFFF]")
> def smart_len(u):
>     sp_count =3D len(SP_PAT.findall(u))
>     return len(u) - sp_count
>=20
>=20
> Problem solved.

Unfortunately only half solved (apart from the fact that it won't work
on Python interpreters compiled for 32 bits but this would be easy to
test) since this won't fix regular expressions that easily!

> The great thing about Python is even when it frustrates you one moment, i=
t=20
> finds a way to quickly make up for it.

I reckon that this is a smart smart_len :-)

Eric

--=20
Rendez-vous =E0 Paris.
                          http://www.technoforum.fr/integ2002/index.html
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------