Commit Graph

22 Commits

Author SHA1 Message Date
Sara Golemon
ebb60ac7dd Add IntlChar class to intl extension
Exposes ICU's uchar functionality as a set of static methods
2015-01-16 14:37:44 -08:00
Anatol Belski
4fce2ae2c6 opcache, intl, gmp, exif, com, bcmath to use static tsrmls 2014-10-17 15:51:21 +02:00
Anatol Belski
4c2330c1e8 make g++ see all the stdint.h stuff 2014-08-20 15:26:53 -07:00
Sara Golemon
5ac35770f4 Add UConverter class (ICU's UConverter API)
RFC at http://wiki.php.net/rfc/uconverter
2012-12-05 15:07:36 -08:00
Gustavo André dos Santos Lopes
06e06f026d Merge branch '5.4'
* 5.4:
  Fix test title and limit it to ICU >= 4.8
  Remove executable bit from files
  Limit test to ICU 49
  Remove executable bit from files
2012-07-30 11:04:48 +02:00
Gustavo André dos Santos Lopes
dec7bad635 Merge branch '5.3' into 5.4
* 5.3:
  Limit test to ICU 49
  Remove executable bit from files
2012-07-30 10:31:10 +02:00
Gustavo André dos Santos Lopes
9762609cec Remove executable bit from files 2012-07-30 10:25:17 +02:00
Gustavo André dos Santos Lopes
99e48d3a57 Merge branch 'datefmt_tz_cal_interop'
* datefmt_tz_cal_interop:
  Readded accidentally removed line
  Added IntlDateFormatter::formatObject(). Refactor
  Refactored internal_get_timestamp()
  Unified zval -> UDate conversions
2012-07-22 04:22:48 +02:00
Gustavo André dos Santos Lopes
2f0775b999 Added IntlDateFormatter::formatObject(). Refactor
To better support IntlCalendar, added this function:

string IntlDateFormatter::formatObject(IntlCalendar|DateTime $obj [,
	array|int|string $format = null [, string $locale = null).

$format is either of the constants IntlDateFormatter::FULL, etc., in
which case this format applies to both the date and the time, an array
in the form array($dateFormat, $timeFormat), or a string with the
SimpleDateFormat pattern.

This uses both the Calendar type and the timezone of the passed object
to configure the formatter (a GregorianCalendar is forced for
DateTime).

Some stuff was moved around and slighlt modified to allow for more code
reuse.
2012-07-22 04:22:23 +02:00
Gustavo André dos Santos Lopes
2416719fb1 Unified zval -> UDate conversions
Now IntlDateFormatter::format() also accepts IntlCalendar objects.
Code is shared in MessageFormatter and IntlDateFormatter.
2012-07-02 00:24:54 +02:00
Gustavo André dos Santos Lopes
0a7ae87e91 Added IntlCodePointBreakIterator.
Objects of this class can be instantiated with

IntlBreakIterator::createCodePointInstance()

The method does not take a locale, as it would not make sense in this
context.

This class has one additional method:

long IntlCodePointIterator::getLastCodePoint()

which returns either -1 or the last code point we moved over, if any
(and discounting any movement before the last call to
IntlBreakIterator::first() or IntlBreakIterator::last()).
2012-06-22 18:19:54 +02:00
Gustavo André dos Santos Lopes
f5b421621d BreakIterator and RuleBasedBreakiterator added
This commit adds wrappers for the classes BreakIterator and
RuleBasedbreakIterator. The C++ ICU classes are described here:
<http://icu-project.org/apiref/icu4c/classBreakIterator.html>
<http://icu-project.org/apiref/icu4c/classRuleBasedBreakIterator.html>

Additionally, a tutorial is available at:
<http://userguide.icu-project.org/boundaryanalysis>

This implementation wraps UTF-8 text in a UText. The text is
iterated without any copying or conversion to UTF-16. There is
also no validation that the input is actually UTF-8; where there
are malformed sequences, the UText will simply U+FFFD.

The class BreakIterator cannot be instantiated directly (has a
private constructor). It provides the interface exposed by the ICU
abstract class with the same name. The PHP class is not abstract
because we may use it to wrap native subclasses of BreakIterator
that we don't know how to wrap. This class includes methods to
move the iterator position to the beginning (first()), to the
end (last()), forward (next()), backwards (previous()), to the
boundary preceding a certain position (preceding()) and following
a certain position (following()) and to obtain the current position
(current()). next() can also be used to advance or recede an
arbitrary number of positions.

BreakIterator also exposes other native methods:
getAvailableLocales(), getLocale() and factory methods to build
several predefined types of BreakIterators: createWordInstance()
for word boundaries, createCharacterInstance() for locale
dependent notions of "characters", createSentenceInstance() for
sentences, createLineInstance() and createTitleInstance() -- for
title casing breaks. These factories currently return
RuleBasedbreakIterators where the names of the rule sets are found
in the ICU data, observing the passed locale (although the locale
is taken into considering there are very few exceptions to the
root rules).

The clone and compare_object PHP object handlers are also
implemented, though the comparison does not yield meaningful results
when used with >, <, >= and <=.

Note that BreakIterator is an iterator only in the sense of the
first 'Iterator' in 'IteratorIterator', i.e., it does not
implement the Iterator interface. The reason is that there is
no sensible implementation for Iterator::key(). Using it for
an ordinal of the current boundary is not feasible because
we are allowed to move to any boundary at any time. It we were
to determine the current ordinal when last() is called we'd
have to traverse the whole input text to find out how many
breaks there were before. Therefore, BreakIterator implements
only Traversable. It can be wrapped in an IteratorIterator,
but the usual warnings apply.

Finally, I added a convenience method to BreakIterator:
getPartsIterator(). This provides an IntlIterator, backed
by the BreakIterator PHP object (i.e. moving the pointer or
changing the text in BreakIterator affects the iterator
and also moving the iterator affects the backing BreakIterator),
which allows traversing the text between each boundary.
This iterator uses the original text to retrieve the text
between two positions, not the code points returned by the
wrapping UText. Therefore, if the text includes invalid code
unit sequences, these invalid sequences will be in the output
of this iterator, not U+FFFD code points.

The class RuleBasedIterator exposes a constructor that allows
building an iterator from arbitrary compiled or non-compiled
rules. The form of these rules in described in the tutorial linked
above. The rest of the methods allow retrieving the rules --
getRules() and getCompiledRules() --, a hash code of the rule set
(hashCode()) and the rules statuses (getRuleStatus() and
getRuleStatusVec()).

Because the RuleBasedBreakIterator constructor may return parse
errors, I reuse the UParseError to text function that was in the
transliterator files. Therefore, I move that function to
intl_error.c.

common_enum.cpp was also changed, mainly to expose previously
static functions. This avoided code duplication when implementing
the BreakIterator iterator and the IntlIterator returned by
BreakIterator::getPartsIterator().
2012-06-04 22:25:07 +02:00
Gustavo André dos Santos Lopes
eb346ef0f4 DateFormat plays nice with Calendar, TimeZone
The following changes were made:

* The IntlDateFormatter constructor now accepts the usual values
  for its $timezone argument. This includes timezone identifiers,
  IntlTimeZone objects, DateTimeZone objects and NULL. An empty
  string is not accepted. An invalid time zone is no longer accepted
  (it used to use UTC in this case).
* When NULL is passed to IntlDateFormatter, the time zone specified in
  date.timezone is used instead of the ICU default.
* The IntlDateFormatter $calendar argument now accepts also an
  IntlCalendar. In this case, IntlDateFormatter::getCalendar() will
  return false.
* The time zone passed to the IntlDateFormatter is ignored if it is
  NULL and if the calendar passed is an IntlCalendar object -- in this
  case, the IntlCalendar time zone will be used instead. Otherwise,
  the time zone specified in the $timezone argument is used instead.
* Added IntlDateFormatter::getCalendarObject(), which always returns
  the IntlCalendar object that backs the DateFormat, even if a
  constant was passed to the constructor, i.e., if an IntlCalendar
  was not passed to the constructor.
* Added IntlDateFormatter::setTimeZone(). It accepts the usual values
  for time zone arguments. If NULL is passed, the time zone of the
  IntlDateFormatter WILL be overridden with the default time zone,
  even if an IntlCalendar object was passed to the constructor.
* Added IntlDateFormatter::getTimeZone(), which returns the time zone
  that's associated with the DateFormat.
* Depreacated IntlDateFormatter::setTimeZoneId() and made it an alias
  for IntlDateFormatter::setTimeZone(), as the new ::setTimeZone()
  also accepts plain identifiers, besides other types.
  IntlDateFormatter::getTimeZoneId() is not deprecated however.
* IntlDateFormatter::setCalendar() with a constant passed should now
  work correctly. This requires saving the requested locale to the
  constructor.
* Centralized the hacks required to avoid compilation disasters on
  Windows due to some headers being included inside and outside of
  extern "C" blocks.
2012-06-04 00:01:48 +02:00
Gustavo André dos Santos Lopes
5e65205a8f Initial checkin of calendar/timezone code. 2012-04-01 23:28:00 +01:00
Pierre Joye
71f5af6c70 - fix build with ICU < 4.2, add ICU_VERSION for m4 checks 2011-02-15 08:28:03 +00:00
Scott MacVicar
d90394851c Add Spoofchecker to intl extension.
Implements part of Unicode TR36 and TR39
2011-01-13 06:53:09 +00:00
Gustavo André dos Santos Lopes
e283f7a7fe - Added support for ICU Transformations (Transliterator).
- Changes request #52986 to "to be documented".
2010-10-06 18:53:27 +00:00
Stanislav Malyshev
8f4337f255 add ICU resource bundle support, contributed by Hans-Peter Oeri 2010-01-04 21:44:45 +00:00
Pierre Joye
503779eb17 - [DOC] add IDN support, idn_to_ascii and idn_to_utf8
tests and MFB will follow Wednesday
2009-01-26 22:30:57 +00:00
Jani Taskinen
39098a6d16 - Fix build 2008-07-16 12:37:00 +00:00
Jani Taskinen
1e2b2bbeae - Some config*.m4 file cleanups: NO tabs in these! 2008-07-14 09:02:26 +00:00
Stanislav Malyshev
0d16b1516b Merge intl extension into core 2008-07-07 22:51:04 +00:00