[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6247] unicode string_width implementation
From: |
Gavin D. Smith |
Subject: |
[6247] unicode string_width implementation |
Date: |
Mon, 04 May 2015 22:06:04 +0000 |
Revision: 6247
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6247
Author: gavin
Date: 2015-05-04 22:06:03 +0000 (Mon, 04 May 2015)
Log Message:
-----------
unicode string_width implementation
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Convert/Unicode.pm
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-05-04 18:13:48 UTC (rev 6246)
+++ trunk/ChangeLog 2015-05-04 22:06:03 UTC (rev 6247)
@@ -1,3 +1,8 @@
+2015-05-03 Gavin Smith <address@hidden>
+
+ * tp/Texinfo/Convert/Unicode.pm (string_width): Calculate string
+ width using "unpack" function.
+
2015-05-03 Karl Berry <address@hidden>
* pretest 5.9.91.
Modified: trunk/tp/Texinfo/Convert/Unicode.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Unicode.pm 2015-05-04 18:13:48 UTC (rev 6246)
+++ trunk/tp/Texinfo/Convert/Unicode.pm 2015-05-04 22:06:03 UTC (rev 6247)
@@ -1459,6 +1459,17 @@
{
my $string = shift;
+ $string =~ s/\p{InFullwidth}/\x{02}/g;
+ $string =~ s/\pM/\x{00}/g;
+ $string =~ s/\p{IsPrint}/\x{01}/g;
+ $string =~ s/\p{IsSpace}/\x{01}/g;
+ $string =~ s/[^\x{01}\x{02}]/\x{00}/g;
+
+ # This sums up the byte values of the bytes in $string, which now are
+ # all either 0, 1 or 2. This is faster. The original, more readable
+ # version is below.
+ return unpack("U0%32A*", $string);
+
if (! defined($string)) {
Carp::cluck();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6247] unicode string_width implementation,
Gavin D. Smith <=