File/ext/utf8/utils/position.php

Description

Locate a byte index given a UTF-8 character index

Functions
utf8_byte_position (line 30)

Given a string and a character index in the string, in

terms of the UTF-8 character position, returns the byte index of that character. Can be useful when you want to PHP's native string functions but we warned, locating the byte can be expensive Takes variable number of parameters - first must be the search string then 1 to n UTF-8 character positions to obtain byte indexes for - it is more efficient to search the string for multiple characters at once, than make repeated calls to this function

mixed utf8_byte_position (string 0, int 1)
  • string 0: string to locate index in
  • int 1: (n times)
utf8_locate_current_chr (line 131)

Given a string and any byte index, returns the byte index

of the start of the current UTF-8 character, relative to supplied position. If the current character begins at the same place as the supplied byte index, that byte index will be returned. Otherwise this function will step backwards, looking for the index where curent UTF-8 character begins

int utf8_locate_current_chr (string &$str, int $idx)
  • string &$str
  • int $idx: byte index in the string
utf8_locate_next_chr (line 159)

Given a string and any byte index, returns the byte index of the start of the next UTF-8 character, relative to supplied position. If the next character begins at the same place as the supplied byte index, that byte index will be returned.

int utf8_locate_next_chr (string &$str, int $idx)
  • string &$str
  • int $idx: byte index in the string

Documentation generated on Thu, 08 Jan 2009 17:47:58 +0100 by phpDocumentor 1.4.0a2