Hello.

I think there's a problem in Stash.xs: length should return _length_ of the 
string, which may be Unicode, instead of its size in bytes. 

See the attached patch (against my system's 2.14, but should apply to the 
trunk) and test case.
-- 
Alexey A. Kiritchun
Yandex, search systems department
developer
--- xs/Stash.xs.orig	2003-03-18 02:05:27.000000000 +0300
+++ xs/Stash.xs	2009-05-18 21:56:48.000000000 +0400
@@ -1230,10 +1230,7 @@
 
 /* scalar.length */
 static SV *scalar_dot_length(pTHX_ SV *sv, AV *args) {
-    STRLEN length;
-    SvPV(sv, length);
-
-    return sv_2mortal(newSViv((IV) length));
+    return sv_2mortal(newSViv((IV) SvUTF8(sv) ? sv_len_utf8(sv): sv_len(sv)));
 }
 
 

Attachment: unicode-length.t
Description: Perl program

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to