note 113541 added to domtext.splittext

From: Date: Mon, 28 Oct 2013 05:31:21 +0000
Subject: note 113541 added to domtext.splittext
Groups: php.notes 
Request: Send a blank email to php-notes+get-197334@lists.php.net to get a copy of this message
It should be noted that $offset is a **character offset**, not a **byte offset**. This means that most other PHP string functions that deal with lengths and offsets (strlen, strpos, preg_match with PREG_OFFSET_CAPTURE, etc.) use and return values unsuitable for this method if used with multibyte strings (like UTF-8 strings). Byte offsets can be converted to character offsets with mb_strlen: <?php function char_offset($string, $byte_offset, $encoding = null) { $substr = substr($string, 0, $byte_offset); return mb_strlen($substr, $encoding ?: mb_internal_encoding()); } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/domtext.splittext.php Edit -- https://master.php.net/note/edit/113541 Del: integrated -- https://master.php.net/note/delete/113541/integrated Del: useless -- https://master.php.net/note/delete/113541/useless Del: bad code -- https://master.php.net/note/delete/113541/bad+code Del: spam -- https://master.php.net/note/delete/113541/spam Del: non-english -- https://master.php.net/note/delete/113541/non-english Del: in docs -- https://master.php.net/note/delete/113541/in+docs Del: other reasons-- https://master.php.net/note/delete/113541 Reject -- https://master.php.net/note/reject/113541 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197334) next »