Revision: 1685
http://mrbs.svn.sourceforge.net/mrbs/?rev=1685&view=rev
Author: jberanek
Date: 2010-12-09 22:58:31 +0000 (Thu, 09 Dec 2010)
Log Message:
-----------
- Added another Unicode support function, utf8_bytecount(). Returns the
number of _bytes_ in a string as opposed to utf8_strlen() which returns
the number of characters. strlen() can't be trusted, as mbstring can
be configured to overload strlen to return character counts.
Modified Paths:
--------------
mrbs/branches/ics_attachments/web/language.inc
Modified: mrbs/branches/ics_attachments/web/language.inc
===================================================================
--- mrbs/branches/ics_attachments/web/language.inc 2010-12-09 21:58:32 UTC
(rev 1684)
+++ mrbs/branches/ics_attachments/web/language.inc 2010-12-09 22:58:31 UTC
(rev 1685)
@@ -807,6 +807,16 @@
}
+// Takes a string (which may be UTF-8) and returns how long it is in
+// _bytes_
+function utf8_bytecount($str)
+{
+ preg_match_all("/./s", $str, $ar);
+
+ return count($ar[0]);
+}
+
+
// Takes a UTF-8 string and returns the string with one Unicode character
// removed from the front
function utf8_next($str)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits