[Po4a-devel]Po4a dependency on libtext-wrapi18n-perl

Martin Quinson martin.quinson@loria.fr
Fri, 3 Jun 2005 15:20:27 +0200


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

Ok, I had another look on this one, and it looks to me that we could quite
easily drop the dependency. The code of this library itself is very close of
what I did in the wrapper part, I think.=20

The first difficulty is to wrap where it's legal, ie after space or after
every CJK char. For that, we could use the same trick than
libtext-wrapi18n-perl:
>>>>>>>>>>>>>>>>>>
# Returns 1 for Chinese and Japanese characters.  This means that
# these characters allow line wrapping after this character even
# without whitespaces because these languages don't use whitespaces
# between words.
#
# Character must be given in UCS-4 codepoint value.

sub _isCJ {
	my $u=3Dshift;

	if ($u >=3D 0x3000 && $u <=3D 0x312f) {
		if ($u =3D=3D 0x300a || $u =3D=3D 0x300c || $u =3D=3D 0x300e ||
		    $u =3D=3D 0x3010 || $u =3D=3D 0x3014 || $u =3D=3D 0x3016 ||
		    $u =3D=3D 0x3018 || $u =3D=3D 0x301a) {return 0;}
		return 1;
	}  # CJK punctuations, Hiragana, Katakana, Bopomofo
	if ($u >=3D 0x31a0 && $u <=3D 0x31bf) {return 1;}  # Bopomofo
	if ($u >=3D 0x31f0 && $u <=3D 0x31ff) {return 1;}  # Katakana extension
	if ($u >=3D 0x3400 && $u <=3D 0x9fff) {return 1;}  # Han Ideogram
	if ($u >=3D 0xf900 && $u <=3D 0xfaff) {return 1;}  # Han Ideogram
	if ($u >=3D 0x20000 && $u <=3D 0x2ffff) {return 1;}  # Han Ideogram

	return 0;
}
<<<<<<<<<<<<<<<<<<<<

Then, the second difficulty is to compute the char width in column right.
Google finds this:
http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c

Reimplementing this in perl seems quite easy. But I'm not sure this source
can be trusted, and I feel just too lazy to download the libc source to see
how it's done in there...

Bye, Mt.

--VywGB/WGlW4DM4P8
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFCoFkaIiC/MeFF8zQRAiGiAJ9CqxCrTzYwyEmEUNoOw/ODZKjPTQCfWBEc
w9kk4SHZ3Hy9LET9aPRmch8=
=HMFn
-----END PGP SIGNATURE-----

--VywGB/WGlW4DM4P8--