Book/intl-Phpdoc专题
Internationalization Functions
目录
- 简介
- 安装/配置
- 预定义常量
- 范例
- Collator — The Collator class
- Collator::asort — Sort array maintaining index association
- Collator::compare — Compare two Unicode strings
- Collator::__construct — Create a collator
- Collator::create — Create a collator
- Collator::getAttribute — Get collation attribute value
- Collator::getErrorCode — Get collator's last error code
- Collator::getErrorMessage — Get text for collator's last error code
- Collator::getLocale — Get the locale name of the collator
- Collator::getSortKey — Get sorting key for a string
- Collator::getStrength — Get current collation strength
- Collator::setAttribute — Set collation attribute
- Collator::setStrength — Set collation strength
- Collator::sortWithSortKeys — Sort array using specified collator and sort keys
- Collator::sort — Sort array using specified collator
- NumberFormatter — The NumberFormatter
class
- NumberFormatter::create — Create a number formatter
- NumberFormatter::formatCurrency — Format a currency value
- NumberFormatter::format — Format a number
- NumberFormatter::getAttribute — Get an attribute
- NumberFormatter::getErrorCode — Get formatter's last error code
- NumberFormatter::getErrorMessage — Get formatter's last error message
- NumberFormatter::getLocale — Get formatter locale
- NumberFormatter::getPattern — Get formatter pattern
- NumberFormatter::getSymbol — Get a symbol value
- NumberFormatter::getTextAttribute — Get a text attribute
- NumberFormatter::parseCurrency — Parse a currency number
- NumberFormatter::parse — Parse a number
- NumberFormatter::setAttribute — Set an attribute
- NumberFormatter::setPattern — Set formatter pattern
- NumberFormatter::setSymbol — Set a symbol value
- NumberFormatter::setTextAttribute — Set a text attribute
- Locale — The Locale class
- Locale::acceptFromHttp — Tries to find out best available locale based on HTTP "Accept-Language" header
- Locale::canonicalize — Canonicalize the locale string
- Locale::composeLocale — Returns a correctly ordered and delimited locale ID
- Locale::filterMatches — Checks if a language tag filter matches with locale
- Locale::getAllVariants — Gets the variants for the input locale
- Locale::getDefault — Gets the default locale value from the INTL global 'default_locale'
- Locale::getDisplayLanguage — Returns an appropriately localized display name for language of the inputlocale
- Locale::getDisplayName — Returns an appropriately localized display name for the input locale
- Locale::getDisplayRegion — Returns an appropriately localized display name for region of the input locale
- Locale::getDisplayScript — Returns an appropriately localized display name for script of the input locale
- Locale::getDisplayVariant — Returns an appropriately localized display name for variants of the input locale
- Locale::getKeywords — Gets the keywords for the input locale
- Locale::getPrimaryLanguage — Gets the primary language for the input locale
- Locale::getRegion — Gets the region for the input locale
- Locale::getScript — Gets the script for the input locale
- Locale::lookup — Searches the language tag list for the best match to the language
- Locale::parseLocale — Returns a key-value array of locale ID subtag elements
- Locale::setDefault — Sets the default runtime locale
- Normalizer — The Normalizer class
- Normalizer::getRawDecomposition — Gets the Decomposition_Mapping property for the given UTF-8 encoded code point
- Normalizer::isNormalized — Checks if the provided string is already in the specified normalization form
- Normalizer::normalize — Normalizes the input provided and returns the normalized string
- MessageFormatter — The
MessageFormatter class
- MessageFormatter::create — Constructs a new Message Formatter
- MessageFormatter::formatMessage — Quick format message
- MessageFormatter::format — Format the message
- MessageFormatter::getErrorCode — Get the error code from last operation
- MessageFormatter::getErrorMessage — Get the error text from the last operation
- MessageFormatter::getLocale — Get the locale for which the formatter was created
- MessageFormatter::getPattern — Get the pattern used by the formatter
- MessageFormatter::parseMessage — Quick parse input string
- MessageFormatter::parse — Parse input string according to pattern
- MessageFormatter::setPattern — Set the pattern used by the formatter
- IntlCalendar — The IntlCalendar class
- IntlCalendar::add — Add a (signed) amount of time to a field
- IntlCalendar::after — Whether this objectʼs time is after that of the passed object
- IntlCalendar::before — Whether this objectʼs time is before that of the passed object
- IntlCalendar::clear — Clear a field or all fields
- IntlCalendar::__construct — Private constructor for disallowing instantiation
- IntlCalendar::createInstance — Create a new IntlCalendar
- IntlCalendar::equals — Compare time of two IntlCalendar objects for equality
- IntlCalendar::fieldDifference — Calculate difference between given time and this objectʼs time
- IntlCalendar::fromDateTime — Create an IntlCalendar from a DateTime object or string
- IntlCalendar::get — Get the value for a field
- IntlCalendar::getActualMaximum — The maximum value for a field, considering the objectʼs current time
- IntlCalendar::getActualMinimum — The minimum value for a field, considering the objectʼs current time
- IntlCalendar::getAvailableLocales — Get array of locales for which there is data
- IntlCalendar::getDayOfWeekType — Tell whether a day is a weekday, weekend or a day that has a transition between the two
- IntlCalendar::getErrorCode — Get last error code on the object
- IntlCalendar::getErrorMessage — Get last error message on the object
- IntlCalendar::getFirstDayOfWeek — Get the first day of the week for the calendarʼs locale
- IntlCalendar::getGreatestMinimum — Get the largest local minimum value for a field
- IntlCalendar::getKeywordValuesForLocale — Get set of locale keyword values
- IntlCalendar::getLeastMaximum — Get the smallest local maximum for a field
- IntlCalendar::getLocale — Get the locale associated with the object
- IntlCalendar::getMaximum — Get the global maximum value for a field
- IntlCalendar::getMinimalDaysInFirstWeek — Get minimal number of days the first week in a year or month can have
- IntlCalendar::getMinimum — Get the global minimum value for a field
- IntlCalendar::getNow — Get number representing the current time
- IntlCalendar::getRepeatedWallTimeOption — Get behavior for handling repeating wall time
- IntlCalendar::getSkippedWallTimeOption — Get behavior for handling skipped wall time
- IntlCalendar::getTime — Get time currently represented by the object
- IntlCalendar::getTimeZone — Get the objectʼs timezone
- IntlCalendar::getType — Get the calendar type
- IntlCalendar::getWeekendTransition — Get time of the day at which weekend begins or ends
- IntlCalendar::inDaylightTime — Whether the objectʼs time is in Daylight Savings Time
- IntlCalendar::isEquivalentTo — Whether another calendar is equal but for a different time
- IntlCalendar::isLenient — Whether date/time interpretation is in lenient mode
- IntlCalendar::isSet — Whether a field is set
- IntlCalendar::isWeekend — Whether a certain date/time is in the weekend
- IntlCalendar::roll — Add value to field without carrying into more significant fields
- IntlCalendar::set — Set a time field or several common fields at once
- IntlCalendar::setFirstDayOfWeek — Set the day on which the week is deemed to start
- IntlCalendar::setLenient — Set whether date/time interpretation is to be lenient
- IntlCalendar::setMinimalDaysInFirstWeek — Set minimal number of days the first week in a year or month can have
- IntlCalendar::setRepeatedWallTimeOption — Set behavior for handling repeating wall times at negative timezone offset transitions
- IntlCalendar::setSkippedWallTimeOption — Set behavior for handling skipped wall times at positive timezone offset transitions
- IntlCalendar::setTime — Set the calendar time in milliseconds since the epoch
- IntlCalendar::setTimeZone — Set the timezone used by this calendar
- IntlCalendar::toDateTime — Convert an IntlCalendar into a DateTime object
- IntlGregorianCalendar — The
IntlGregorianCalendar class
- IntlGregorianCalendar::__construct — Create the Gregorian Calendar class
- IntlGregorianCalendar::getGregorianChange — Get the Gregorian Calendar change date
- IntlGregorianCalendar::isLeapYear — Determine if the given year is a leap year
- IntlGregorianCalendar::setGregorianChange — Set the Gregorian Calendar the change date
- IntlTimeZone — The IntlTimeZone class
- IntlTimeZone::countEquivalentIDs — Get the number of IDs in the equivalency group that includes the given ID
- IntlTimeZone::createDefault — Create a new copy of the default timezone for this host
- IntlTimeZone::createEnumeration — Get an enumeration over time zone IDs associated with the given country or offset
- IntlTimeZone::createTimeZone — Create a timezone object for the given ID
- IntlTimeZone::createTimeZoneIDEnumeration — Get an enumeration over system time zone IDs with the given filter conditions
- IntlTimeZone::fromDateTimeZone — Create a timezone object from DateTimeZone
- IntlTimeZone::getCanonicalID — Get the canonical system timezone ID or the normalized custom time zone ID for the given time zone ID
- IntlTimeZone::getDisplayName — Get a name of this time zone suitable for presentation to the user
- IntlTimeZone::getDSTSavings — Get the amount of time to be added to local standard time to get local wall clock time
- IntlTimeZone::getEquivalentID — Get an ID in the equivalency group that includes the given ID
- IntlTimeZone::getErrorCode — Get last error code on the object
- IntlTimeZone::getErrorMessage — Get last error message on the object
- IntlTimeZone::getGMT — Create GMT (UTC) timezone
- IntlTimeZone::getID — Get timezone ID
- IntlTimeZone::getIDForWindowsID — Translate a Windows timezone into a system timezone
- IntlTimeZone::getOffset — Get the time zone raw and GMT offset for the given moment in time
- IntlTimeZone::getRawOffset — Get the raw GMT offset (before taking daylight savings time into account
- IntlTimeZone::getRegion — Get the region code associated with the given system time zone ID
- IntlTimeZone::getTZDataVersion — Get the timezone data version currently used by ICU
- IntlTimeZone::getUnknown — Get the "unknown" time zone
- IntlTimeZone::getWindowsID — Translate a system timezone into a Windows timezone
- IntlTimeZone::hasSameRules — Check if this zone has the same rules and offset as another zone
- IntlTimeZone::toDateTimeZone — Convert to DateTimeZone object
- IntlTimeZone::useDaylightTime — Check if this time zone uses daylight savings time
- IntlDateFormatter — The
IntlDateFormatter class
- IntlDateFormatter::create — Create a date formatter
- IntlDateFormatter::format — Format the date/time value as a string
- IntlDateFormatter::formatObject — Formats an object
- IntlDateFormatter::getCalendar — Get the calendar type used for the IntlDateFormatter
- IntlDateFormatter::getDateType — Get the datetype used for the IntlDateFormatter
- IntlDateFormatter::getErrorCode — Get the error code from last operation
- IntlDateFormatter::getErrorMessage — Get the error text from the last operation
- IntlDateFormatter::getLocale — Get the locale used by formatter
- IntlDateFormatter::getPattern — Get the pattern used for the IntlDateFormatter
- IntlDateFormatter::getTimeType — Get the timetype used for the IntlDateFormatter
- IntlDateFormatter::getTimeZoneId — Get the timezone-id used for the IntlDateFormatter
- IntlDateFormatter::getCalendarObject — Get copy of formatterʼs calendar object
- IntlDateFormatter::getTimeZone — Get formatterʼs timezone
- IntlDateFormatter::isLenient — Get the lenient used for the IntlDateFormatter
- IntlDateFormatter::localtime — Parse string to a field-based time value
- IntlDateFormatter::parse — Parse string to a timestamp value
- IntlDateFormatter::setCalendar — Sets the calendar type used by the formatter
- IntlDateFormatter::setLenient — Set the leniency of the parser
- IntlDateFormatter::setPattern — Set the pattern used for the IntlDateFormatter
- IntlDateFormatter::setTimeZoneId — Sets the time zone to use
- IntlDateFormatter::setTimeZone — Sets formatterʼs timezone
- ResourceBundle — The ResourceBundle
class
- ResourceBundle::count — Get number of elements in the bundle
- ResourceBundle::create — Create a resource bundle
- ResourceBundle::getErrorCode — Get bundle's last error code
- ResourceBundle::getErrorMessage — Get bundle's last error message
- ResourceBundle::get — Get data from the bundle
- ResourceBundle::getLocales — Get supported locales
- Spoofchecker — The Spoofchecker class
- Spoofchecker::areConfusable — Checks if given strings can be confused
- Spoofchecker::__construct — Constructor
- Spoofchecker::isSuspicious — Checks if a given text contains any suspicious characters
- Spoofchecker::setAllowedLocales — Locales to use when running checks
- Spoofchecker::setChecks — Set the checks to run
- Transliterator — The Transliterator
class
- Transliterator::__construct — Private constructor to deny instantiation
- Transliterator::create — Create a transliterator
- Transliterator::createFromRules — Create transliterator from rules
- Transliterator::createInverse — Create an inverse transliterator
- Transliterator::getErrorCode — Get last error code
- Transliterator::getErrorMessage — Get last error message
- Transliterator::listIDs — Get transliterator IDs
- Transliterator::transliterate — Transliterate a string
- IntlBreakIterator — The
IntlBreakIterator class
- IntlBreakIterator::__construct — Private constructor for disallowing instantiation
- IntlBreakIterator::createCharacterInstance — Create break iterator for boundaries of combining character sequences
- IntlBreakIterator::createCodePointInstance — Create break iterator for boundaries of code points
- IntlBreakIterator::createLineInstance — Create break iterator for logically possible line breaks
- IntlBreakIterator::createSentenceInstance — Create break iterator for sentence breaks
- IntlBreakIterator::createTitleInstance — Create break iterator for title-casing breaks
- IntlBreakIterator::createWordInstance — Create break iterator for word breaks
- IntlBreakIterator::current — Get index of current position
- IntlBreakIterator::first — Set position to the first character in the text
- IntlBreakIterator::following — Advance the iterator to the first boundary following specified offset
- IntlBreakIterator::getErrorCode — Get last error code on the object
- IntlBreakIterator::getErrorMessage — Get last error message on the object
- IntlBreakIterator::getLocale — Get the locale associated with the object
- IntlBreakIterator::getPartsIterator — Create iterator for navigating fragments between boundaries
- IntlBreakIterator::getText — Get the text being scanned
- IntlBreakIterator::isBoundary — Tell whether an offset is a boundaryʼs offset
- IntlBreakIterator::last — Set the iterator position to index beyond the last character
- IntlBreakIterator::next — Advance the iterator the next boundary
- IntlBreakIterator::preceding — Set the iterator position to the first boundary before an offset
- IntlBreakIterator::previous — Set the iterator position to the boundary immediately before the current
- IntlBreakIterator::setText — Set the text being scanned
- IntlRuleBasedBreakIterator
— The IntlRuleBasedBreakIterator class
- IntlRuleBasedBreakIterator::__construct — Create iterator from ruleset
- IntlRuleBasedBreakIterator::getBinaryRules — Get the binary form of compiled rules
- IntlRuleBasedBreakIterator::getRules — Get the rule set used to create this object
- IntlRuleBasedBreakIterator::getRuleStatus — Get the largest status value from the break rules that determined the current break position
- IntlRuleBasedBreakIterator::getRuleStatusVec — Get the status values from the break rules that determined the current break position
- IntlCodePointBreakIterator
— The IntlCodePointBreakIterator class
- IntlCodePointBreakIterator::getLastCodePoint — Get last code point passed over after advancing or receding the iterator
- IntlPartsIterator — The
IntlPartsIterator class
- IntlPartsIterator::getBreakIterator — Get IntlBreakIterator backing this parts iterator
- UConverter — The UConverter class
- UConverter::__construct — Create UConverter object
- UConverter::convert — Convert string from one charset to another
- UConverter::fromUCallback — Default "from" callback function
- UConverter::getAliases — Get the aliases of the given name
- UConverter::getAvailable — Get the available canonical converter names
- UConverter::getDestinationEncoding — Get the destination encoding
- UConverter::getDestinationType — Get the destination converter type
- UConverter::getErrorCode — Get last error code on the object
- UConverter::getErrorMessage — Get last error message on the object
- UConverter::getSourceEncoding — Get the source encoding
- UConverter::getSourceType — Get the source converter type
- UConverter::getStandards — Get standards associated to converter names
- UConverter::getSubstChars — Get substitution chars
- UConverter::reasonText — Get string representation of the callback reason
- UConverter::setDestinationEncoding — Set the destination encoding
- UConverter::setSourceEncoding — Set the source encoding
- UConverter::setSubstChars — Set the substitution chars
- UConverter::toUCallback — Default "to" callback function
- UConverter::transcode — Convert string from one charset to another
- Grapheme 函数
- grapheme_extract — Function to extract a sequence of default grapheme clusters from a text buffer, which must be encoded in UTF-8
- grapheme_stripos — Find position (in grapheme units) of first occurrence of a case-insensitive string
- grapheme_stristr — Returns part of haystack string from the first occurrence of case-insensitive needle to the end of haystack
- grapheme_strlen — Get string length in grapheme units
- grapheme_strpos — Find position (in grapheme units) of first occurrence of a string
- grapheme_strripos — Find position (in grapheme units) of last occurrence of a case-insensitive string
- grapheme_strrpos — Find position (in grapheme units) of last occurrence of a string
- grapheme_strstr — Returns part of haystack string from the first occurrence of needle to the end of haystack
- grapheme_substr — Return part of a string
- IDN 函数
- idn_to_ascii — Convert domain name to IDNA ASCII form
- idn_to_utf8 — Convert domain name from IDNA ASCII to Unicode
- IntlChar — IntlChar
- IntlChar::charAge — Get the "age" of the code point
- IntlChar::charDigitValue — Get the decimal digit value of a decimal digit character
- IntlChar::charDirection — Get bidirectional category value for a code point
- IntlChar::charFromName — Find Unicode character by name and return its code point value
- IntlChar::charMirror — Get the "mirror-image" character for a code point
- IntlChar::charName — Retrieve the name of a Unicode character
- IntlChar::charType — Get the general category value for a code point
- IntlChar::chr — Return Unicode character by code point value
- IntlChar::digit — Get the decimal digit value of a code point for a given radix
- IntlChar::enumCharNames — Enumerate all assigned Unicode characters within a range
- IntlChar::enumCharTypes — Enumerate all code points with their Unicode general categories
- IntlChar::foldCase — Perform case folding on a code point
- IntlChar::forDigit — Get character representation for a given digit and radix
- IntlChar::getBidiPairedBracket — Get the paired bracket character for a code point
- IntlChar::getBlockCode — Get the Unicode allocation block containing a code point
- IntlChar::getCombiningClass — Get the combining class of a code point
- IntlChar::getFC_NFKC_Closure — Get the FC_NFKC_Closure property for a code point
- IntlChar::getIntPropertyMaxValue — Get the max value for a Unicode property
- IntlChar::getIntPropertyMinValue — Get the min value for a Unicode property
- IntlChar::getIntPropertyValue — Get the value for a Unicode property for a code point
- IntlChar::getNumericValue — Get the numeric value for a Unicode code point
- IntlChar::getPropertyEnum — Get the property constant value for a given property name
- IntlChar::getPropertyName — Get the Unicode name for a property
- IntlChar::getPropertyValueEnum — Get the property value for a given value name
- IntlChar::getPropertyValueName — Get the Unicode name for a property value
- IntlChar::getUnicodeVersion — Get the Unicode version
- IntlChar::hasBinaryProperty — Check a binary Unicode property for a code point
- IntlChar::isalnum — Check if code point is an alphanumeric character
- IntlChar::isalpha — Check if code point is a letter character
- IntlChar::isbase — Check if code point is a base character
- IntlChar::isblank — Check if code point is a "blank" or "horizontal space" character
- IntlChar::iscntrl — Check if code point is a control character
- IntlChar::isdefined — Check whether the code point is defined
- IntlChar::isdigit — Check if code point is a digit character
- IntlChar::isgraph — Check if code point is a graphic character
- IntlChar::isIDIgnorable — Check if code point is an ignorable character
- IntlChar::isIDPart — Check if code point is permissible in an identifier
- IntlChar::isIDStart — Check if code point is permissible as the first character in an identifier
- IntlChar::isISOControl — Check if code point is an ISO control code
- IntlChar::isJavaIDPart — Check if code point is permissible in a Java identifier
- IntlChar::isJavaIDStart — Check if code point is permissible as the first character in a Java identifier
- IntlChar::isJavaSpaceChar — Check if code point is a space character according to Java
- IntlChar::islower — Check if code point is a lowercase letter
- IntlChar::isMirrored — Check if code point has the Bidi_Mirrored property
- IntlChar::isprint — Check if code point is a printable character
- IntlChar::ispunct — Check if code point is punctuation character
- IntlChar::isspace — Check if code point is a space character
- IntlChar::istitle — Check if code point is a titlecase letter
- IntlChar::isUAlphabetic — Check if code point has the Alphabetic Unicode property
- IntlChar::isULowercase — Check if code point has the Lowercase Unicode property
- IntlChar::isupper — Check if code point has the general category "Lu" (uppercase letter)
- IntlChar::isUUppercase — Check if code point has the Uppercase Unicode property
- IntlChar::isUWhiteSpace — Check if code point has the White_Space Unicode property
- IntlChar::isWhitespace — Check if code point is a whitespace character according to ICU
- IntlChar::isxdigit — Check if code point is a hexadecimal digit
- IntlChar::ord — Return Unicode code point value of character
- IntlChar::tolower — Make Unicode character lowercase
- IntlChar::totitle — Make Unicode character titlecase
- IntlChar::toupper — Make Unicode character uppercase
- IntlException — Exception class for intl errors
- IntlIterator — The IntlIterator class
- IntlIterator::current — Get the current element
- IntlIterator::key — Get the current key
- IntlIterator::next — Move forward to the next element
- IntlIterator::rewind — Rewind the iterator to the first element
- IntlIterator::valid — Check if current position is valid
- intl 函数
- intl_error_name — Get symbolic name for a given error code
- intl_get_error_code — Get the last error code
- intl_get_error_message — Get description of the last error
- intl_is_failure — Check whether the given error code indicates failure
简介
Provides string comparison capability with support for appropriate locale-sensitive sort orderings.
类摘要
Collator
class Collator {
/* 方法 */
public <span
class="methodname">__construct ( <span
class="methodparam">string $locale
)
public bool
asort ( <span
class="type">array &$arr
[, <span
class="methodparam">int $sort_flag
]
)
public int <span
class="methodname">compare ( <span
class="type">string $str1
, <span
class="methodparam">string $str2
)
public <span
class="modifier">static Collator <span
class="methodname">create ( <span
class="type">string $locale
)
public int <span
class="methodname">getAttribute ( <span
class="type">int $attr
)
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
public string
getLocale ( <span
class="methodparam">int $type
)
public <span
class="type">stringfalse <span
class="methodname">getSortKey ( <span
class="type">string $str
)
public int <span class="methodname">getStrength ( <span class="methodparam">void )
public bool
setAttribute ( <span
class="methodparam">int $attr
, <span
class="methodparam">int $val
)
public bool
setStrength ( <span
class="methodparam">int $strength
)
public bool
sortWithSortKeys ( <span
class="methodparam">array &$arr
)
public bool
sort ( <span
class="type">array &$arr
[, <span
class="methodparam">int $sort_flag
]
)
}
预定义常量
Collator::FRENCH_COLLATION
(int)
Sort strings with different accents from the back of the string. This
attribute is automatically set to On for the French locales and a few
others. Users normally would not need to explicitly set this attribute.
There is a string comparison performance cost when it is set On, but
sort key length is unaffected. Possible values are:
Collator::ON
Collator::OFF
(default)Collator::DEFAULT_VALUE
示例 #1 FRENCH_COLLATION rules
- F=OFF cote \< coté \< côte \< côté
- F=ON cote \< côte \< coté \< côté
Collator::ALTERNATE_HANDLING
(int)
The Alternate attribute is used to control the handling of the so called
variable characters in the UCA: whitespace, punctuation and symbols. If
Alternate is set to NonIgnorable (N), then differences among these
characters are of the same importance as differences among letters. If
Alternate is set to Shifted (S), then these characters are of only
minor importance. The Shifted value is often used in combination with
Strength set to Quaternary. In such a case, whitespace, punctuation,
and symbols are considered when comparing strings, but only if all other
aspects of the strings (base letters, accents, and case) are identical.
If Alternate is not set to Shifted, then there is no difference between
a Strength of 3 and a Strength of 4. For more information and examples,
see Variable_Weighting in the
» UCA.
The reason the Alternate values are not simply On and Off is that
additional Alternate values may be added in the future. The UCA option
Blanked is expressed with Strength set to 3, and Alternate set to
Shifted. The default for most locales is NonIgnorable. If Shifted is
selected, it may be slower if there are many strings that are the same
except for punctuation; sort key length will not be affected unless the
strength level is also increased.
Possible values are:
Collator::NON_IGNORABLE
(default)Collator::SHIFTED
Collator::DEFAULT_VALUE
示例 #2 ALTERNATE_HANDLING rules
- S=3, A=N di Silva \< Di Silva \< diSilva \< U.S.A. \< USA
- S=3, A=S di Silva = diSilva \< Di Silva \< U.S.A. = USA
- S=4, A=S di Silva \< diSilva \< Di Silva \< U.S.A. \< USA
Collator::CASE_FIRST
(int)
The Case_First attribute is used to control whether uppercase letters
come before lowercase letters or vice versa, in the absence of other
differences in the strings. The possible values are
Uppercase_First (U) and Lowercase_First (L), plus the standard
Default and Off. There is almost no difference between the Off and
Lowercase_First options in terms of results, so typically users will
not use Lowercase_First: only Off or Uppercase_First. (People
interested in the detailed differences between X and L should consult
the Collation Customization). Specifying either L or U won't affect
string comparison performance, but will affect the sort key length.
Possible values are:
Collator::OFF
(default)Collator::LOWER_FIRST
Collator::UPPER_FIRST
Collator:DEFAULT
示例 #3 CASE_FIRST rules
- C=X or C=L "china" \< "China" \< "denmark" \< "Denmark"
- C=U "China" \< "china" \< "Denmark" \< "denmark"
Collator::CASE_LEVEL
(int)
The Case_Level attribute is used when ignoring accents but not case. In
such a situation, set Strength to be Primary, and Case_Level to be
On. In most locales, this setting is Off by default. There is a small
string comparison performance and sort key impact if this attribute is
set to be On.
Possible values are:
Collator::OFF
(default)Collator::ON
Collator::DEFAULT_VALUE
示例 #4 CASE_LEVEL rules
- S=1, E=X role = Role = rôle
- S=1, E=O role = rôle \< Role
Collator::NORMALIZATION_MODE
(int)
The Normalization setting determines whether text is thoroughly
normalized or not in comparison. Even if the setting is off (which is
the default for many locales), text as represented in common usage will
compare correctly (for details, see UTN #5). Only if the accent marks
are in noncanonical order will there be a problem. If the setting is
On, then the best results are guaranteed for all possible text input.
There is a medium string comparison performance cost if this attribute
is On, depending on the frequency of sequences that require
normalization. There is no significant effect on sort key length. If the
input text is known to be in NFD or NFKD normalization forms, there is
no need to enable this Normalization option.
Possible values are:
Collator::OFF
(default)Collator::ON
Collator::DEFAULT_VALUE
Collator::STRENGTH
(int)
The ICU Collation Service supports many levels of comparison (named
"Levels", but also known as "Strengths"). Having these categories
enables ICU to sort strings precisely according to local conventions.
However, by allowing the levels to be selectively employed, searching
for a string in text can be performed with various matching conditions.
For more detailed information, see <span
class="function">collator_set_strength chapter.
Possible values are:
Collator::PRIMARY
Collator::SECONDARY
Collator::TERTIARY
(default)Collator::QUATERNARY
Collator::IDENTICAL
Collator::DEFAULT_VALUE
Collator::HIRAGANA_QUATERNARY_MODE
(int)
Compatibility with JIS x 4061 requires the introduction of an additional
level to distinguish Hiragana and Katakana characters. If compatibility
with that standard is required, then this attribute should be set On,
and the strength set to Quaternary. This will affect sort key length and
string comparison string comparison performance.
Possible values are:
Collator::OFF
(default)Collator::ON
Collator::DEFAULT_VALUE
Collator::NUMERIC_COLLATION
(int)
When turned on, this attribute generates a collation key for the numeric
value of substrings of digits. This is a way to get '100' to sort AFTER
'2'.
Possible values are:
Collator::OFF
(default)Collator::ON
Collator::DEFAULT_VALUE
Collator::DEFAULT_VALUE
(int)
Collator::PRIMARY
(int)
Collator::SECONDARY
(int)
Collator::TERTIARY
(int)
Collator::DEFAULT_STRENGTH
(int)
Collator::QUATERNARY
(int)
Collator::IDENTICAL
(int)
Collator::OFF
(int)
Collator::ON
(int)
Collator::SHIFTED
(int)
Collator::NON_IGNORABLE
(int)
Collator::LOWER_FIRST
(int)
Collator::UPPER_FIRST
(int)
Collator::asort
collator_asort
Sort array maintaining index association
说明
面向对象风格
public bool
Collator::asort ( <span
class="methodparam">array &$arr
[,
int
$sort_flag
] )
过程化风格
bool <span
class="methodname">collator_asort ( <span
class="methodparam">Collator $coll
,
array &$arr
[, int
$sort_flag
] )
This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. Array elements will have sort order according to current locale rules.
Equivalent to standard PHP asort.
参数
coll
Collator object.
arr
Array of strings to sort.
sort_flag
Optional sorting type, one of the following:
-
Collator::SORT_REGULAR
- compare items normally (don't change types) -
Collator::SORT_NUMERIC
- compare items numerically -
Collator::SORT_STRING
- compare items as strings
Default $sort_flag value is Collator::SORT_REGULAR
. It is also
used if an invalid $sort_flag value has been specified.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 collator_asortexample
<?php
$coll = collator_create( 'en_US' );
$arr = array(
'a' => '100',
'b' => '50',
'c' => '7'
);
collator_asort( $coll, $arr, Collator::SORT_NUMERIC );
var_export( $arr );
collator_asort( $coll, $arr, Collator::SORT_STRING );
var_export( $arr );
?>
以上例程会输出:
array (
'c' => '7',
'b' => '50',
'a' => '100',
)array (
'a' => '100',
'b' => '50',
'c' => '7',
)
参见
- Collator constants
- collator_sort
- collator_sort_with_sort_keys
Collator::compare
collator_compare
Compare two Unicode strings
说明
面向对象风格
public int <span
class="methodname">Collator::compare ( <span
class="methodparam">string $str1
,
string
$str2
)
过程化风格
int <span
class="methodname">collator_compare ( <span
class="methodparam">Collator $coll
,
string
$str1
, <span
class="type">string $str2
)
Compare two Unicode strings according to collation rules.
参数
coll
Collator object.
str1
The first string to compare.
str2
The second string to compare.
返回值
Return comparison result:
-
1 if
str1
is greater thanstr2
; -
0 if
str1
is equal tostr2
; -
-1 if
str1
is less thanstr2
.
On error bool false
is returned.
Warning
此函数可能返回布尔值 false
,但也可能返回等同于 false
的非布尔值。请阅读
布尔类型章节以获取更多信息。应使用
=== 运算符来测试此函数的返回值。
范例
示例 #1 collator_compareexample
<?php
$s1 = 'Hello';
$s2 = 'hello';
$coll = collator_create( 'en_US' );
$res = collator_compare( $coll, $s1, $s2 );
if ($res === false) {
echo collator_get_error_message( $coll );
} else if( $res > 0 ) {
echo "s1 is greater than s2\n";
} else if( $res < 0 ) {
echo "s1 is less than s2\n";
} else {
echo "s1 is equal to s2\n";
}
?>
以上例程会输出:
s1 is greater than s2
参见
- collator_sort
Collator::__construct
Create a collator
说明
public <span
class="methodname">Collator::__construct ( <span
class="methodparam">string $locale
)
Creates a new instance of Collator.
参数
locale
The locale whose collation rules should be used. Special values for
locales can be passed in - if null is passed for the locale, the default
locale's collation rules will be used. If "root" is passed, UCA rules
will be used.
The Locale attribute is typically the most important attribute for correct sorting and matching, according to the user expectations in different countries and regions. The default » UCA ordering will only sort a few languages such as Dutch and Portuguese correctly ("correctly" meaning according to the normal expectations for users of the languages). Otherwise, you need to supply the locale to UCA in order to properly collate text for a given language. Thus a locale needs to be supplied so as to choose a collator that is correctly tailored for that locale. The choice of a locale will automatically preset the values for all of the attributes to something that is reasonable for that locale. Thus most of the time the other attributes do not need to be explicitly set. In some cases, the choice of locale will make a difference in string comparison performance and/or sort key length.
返回值
Returns Collator instance.
错误/异常
Returns an "empty" object on error. You can use <span class="function">intl_get_error_code and/or <span class="function">intl_get_error_message to know what happened.
范例
示例 #1 Collator::__construct example
<?php
$coll = new Collator( 'en_CA' );
?>
参见
- Collator::create
- collator_create
Collator::create
collator_create
Create a collator
说明
面向对象风格
public <span
class="modifier">static Collator <span
class="methodname">Collator::create ( <span
class="methodparam">string $locale
)
过程化风格
Collator <span
class="methodname">collator_create ( <span
class="methodparam">string $locale
)
The strings will be compared using the options already specified.
参数
locale
The locale containing the required collation rules. Special values for
locales can be passed in - if null is passed for the locale, the default
locale collation rules will be used. If empty string ("") or "root" are
passed,
» UCA
rules will be used.
返回值
Return new instance of Collator object,
or null
on error.
范例
示例 #1 collator_create example
<?php
$coll = collator_create( 'en_US' );
if( !isset( $coll ) ) {
printf( "Collator creation failed: %s\n", intl_get_error_message() );
exit( 1 );
}
?>
参见
- Collator::__construct
Collator::getAttribute
collator_get_attribute
Get collation attribute value
说明
面向对象风格
public int <span
class="methodname">Collator::getAttribute ( <span
class="methodparam">int $attr
)
过程化风格
int <span
class="methodname">collator_get_attribute ( <span
class="methodparam">Collator $coll
,
int $attr
)
Get a value of an integer collator attribute.
参数
coll
Collator object.
attr
Attribute to get value for.
返回值
Attribute value, or bool false
on error.
范例
示例 #1 collator_get_attribute example
<?php
$coll = collator_create( 'en_CA' );
$val = collator_get_attribute( $coll, Collator::NUMERIC_COLLATION );
if( $val === false )
{
// Handle error.
}
?>
参见
- Collator constants
- collator_set_attribute
- collator_get_strength
Collator::getErrorCode
collator_get_error_code
Get collator's last error code
说明
面向对象风格
public int <span class="methodname">Collator::getErrorCode ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">collator_get_error_code ( <span
class="methodparam">Collator $coll
)
参数
coll
Collator object.
返回值
Error code returned by the last Collator API function call.
范例
示例 #1 collator_get_error_code example
<?php
$coll = collator_create( 'en_US' );
if( collator_get_attribute( $coll, Collator::FRENCH_COLLATION ) === false )
handle_error( collator_get_error_code() );
?>
参见
- collator_get_error_message
Collator::getErrorMessage
collator_get_error_message
Get text for collator's last error code
说明
面向对象风格
public string Collator::getErrorMessage ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">collator_get_error_message ( <span
class="methodparam">Collator $coll
)
Retrieves the message for the last error.
参数
coll
Collator object.
返回值
Description of an error occurred in the last Collator API function call.
范例
示例 #1 collator_get_error_message example
<?php
$coll = collator_create( 'lt' );
if( collator_compare( $coll, 'y', 'k' ) === false ) {
echo collator_get_error_message( $coll );
}
?>
参见
- collator_get_error_code
Collator::getLocale
collator_get_locale
Get the locale name of the collator
说明
面向对象风格
public string
Collator::getLocale ( <span
class="methodparam">int $type
)
过程化风格
string <span
class="methodname">collator_get_locale ( <span
class="methodparam">Collator $coll
,
int $type
)
Get collector locale name.
参数
coll
Collator object.
type
You can choose between valid and actual locale (
Locale::VALID_LOCALE
and Locale::ACTUAL_LOCALE
,
respectively).
返回值
Real locale name from which the collation data comes. If the collator
was instantiated from rules or an error occurred, returns <span
class="type">bool false
.
范例
示例 #1 collator_get_locale example
<?php
$coll = collator_create( 'en_US_California' );
$res_val = collator_get_locale( $coll, Locale::VALID_LOCALE );
$res_act = collator_get_locale( $coll, Locale::ACTUAL_LOCALE );
printf( "Valid locale name: %s\nActual locale name: %s\n",
$res_val, $res_act );
?>
以上例程会输出:
Requested locale name: en_US_California
Valid locale name: en_US
Actual locale name: en
参见
- collator_create
Collator::getSortKey
collator_get_sort_key
Get sorting key for a string
说明
面向对象风格
public <span
class="type">stringfalse <span
class="methodname">Collator::getSortKey ( <span
class="methodparam">string $str
)
过程化风格
string<span
class="type">false <span
class="methodname">collator_get_sort_key ( <span
class="methodparam">Collator $coll
,
string $str
)
Return collation key for a string. Collation keys can be compared directly instead of strings, though are implementation specific and may change between ICU library versions. Sort keys are generally only useful in databases or other circumstances where function calls are extremely expensive.
参数
coll
Collator object.
str
The string to produce the key from.
返回值
Returns the collation key for the string, 或者在失败时返回 false
.
Warning
此函数可能返回布尔值 false
,但也可能返回等同于 false
的非布尔值。请阅读
布尔类型章节以获取更多信息。应使用
=== 运算符来测试此函数的返回值。
更新日志
版本 | 说明 |
---|---|
5.3.15, 5.4.5 | Sort keys do no longer contain any NUL bytes. |
范例
示例 #1 <span class="function">collator_get_sort_keyexample
<?php
$s1 = 'Hello';
$coll = collator_create('en_US');
$res = collator_get_sort_key($coll, $s1);
echo bin2hex($res);
?>
以上例程的输出类似于:
3832404046010901dc08
参见
- collator_sort
- collator_sort_with_sort_keys
Collator::getStrength
collator_get_strength
Get current collation strength
说明
面向对象风格
public int <span class="methodname">Collator::getStrength ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">collator_get_strength ( <span
class="methodparam">Collator $coll
)
参数
coll
Collator object.
返回值
Returns current collation strength, or bool
false
on error.
范例
示例 #1 collator_get_strength example
<?php
$coll = collator_create( 'en_US' );
$strength = collator_get_strength( $coll );
?>
参见
- Collator constants
- collator_set_strength
- collator_get_attribute
Collator::setAttribute
collator_set_attribute
Set collation attribute
说明
面向对象风格
public bool
Collator::setAttribute ( <span
class="methodparam">int $attr
, <span
class="methodparam">int $val
)
过程化风格
bool <span
class="methodname">collator_set_attribute ( <span
class="methodparam">Collator $coll
,
int $attr
,
int $val
)
参数
coll
Collator <span
class="type">object.
attr
Attribute.
val
Attribute value.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 collator_set_attribute example
<?php
$coll = collator_create( 'en_CA' );
$val = collator_get_attribute( $coll, Collator::NUMERIC_COLLATION );
if ($val === false) {
// Handle error.
} elseif ($val === Collator::ON) {
// Do something useful.
}
?>
参见
- Collator constants
- collator_get_attribute
- collator_set_strength
Collator::setStrength
collator_set_strength
Set collation strength
说明
面向对象风格
public bool
Collator::setStrength ( <span
class="methodparam">int $strength
)
过程化风格
bool <span
class="methodname">collator_set_strength ( <span
class="methodparam">Collator $coll
,
int
$strength
)
The » ICU Collation Service supports many levels of comparison (named "Levels", but also known as "Strengths"). Having these categories enables ICU to sort strings precisely according to local conventions. However, by allowing the levels to be selectively employed, searching for a string in text can be performed with various matching conditions.
-
Primary Level: Typically, this is used to denote differences between base characters (for example, "a" \< "b"). It is the strongest difference. For example, dictionaries are divided into different sections by base character. This is also called the level1 strength.
-
Secondary Level: Accents in the characters are considered secondary differences (for example, "as" \< "às" \< "at"). Other differences between letters can also be considered secondary differences, depending on the language. A secondary difference is ignored when there is a primary difference anywhere in the strings. This is also called the level2 strength.
Note:
Note: In some languages (such as Danish), certain accented letters are considered to be separate base characters. In most languages, however, an accented letter only has a secondary difference from the unaccented version of that letter.
-
Tertiary Level: Upper and lower case differences in characters are distinguished at the tertiary level (for example, "ao" \< "Ao" \< "aò"). In addition, a variant of a letter differs from the base form on the tertiary level (such as "A" and " "). Another example is the difference between large and small Kana. A tertiary difference is ignored when there is a primary or secondary difference anywhere in the strings. This is also called the level3 strength.
-
Quaternary Level: When punctuation is ignored (see Ignoring Punctuations ) at level 13, an additional level can be used to distinguish words with and without punctuation (for example, "ab" \< "a-b" \< "aB"). This difference is ignored when there is a primary, secondary or tertiary difference. This is also known as the level4 strength. The quaternary level should only be used if ignoring punctuation is required or when processing Japanese text (see Hiragana processing).
-
Identical Level: When all other levels are equal, the identical level is used as a tiebreaker. The Unicode code point values of the NFD form of each string are compared at this level, just in case there is no difference at levels 14. For example, Hebrew cantillation marks are only distinguished at this level. This level should be used sparingly, as only code point values differences between two strings is an extremely rare occurrence. Using this level substantially decreases the performance for both incremental comparison and sort key generation (as well as increasing the sort key length). It is also known as level 5 strength.
For example, people may choose to ignore accents or ignore accents and case when searching for text. Almost all characters are distinguished by the first three levels, and in most locales the default value is thus Tertiary. However, if Alternate is set to be Shifted, then the Quaternary strength can be used to break ties among whitespace, punctuation, and symbols that would otherwise be ignored. If very fine distinctions among characters are required, then the Identical strength can be used (for example, Identical Strength distinguishes between the Mathematical Bold Small A and the Mathematical Italic Small A.). However, using levels higher than Tertiary the Identical strength result in significantly longer sort keys, and slower string comparison performance for equal strings.
参数
coll
Collator object.
strength
Strength to set.
Possible values are:
-
Collator::PRIMARY
-
Collator::SECONDARY
-
Collator::TERTIARY
-
Collator::QUATERNARY
-
Collator::IDENTICAL
-
Collator::DEFAULT_STRENGTH
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 collator_set_strength example
<?php
$arr = array( 'aò', 'Ao', 'ao' );
$coll = collator_create( 'en_US' );
// Sort array using default strength.
collator_sort( $coll, $arr );
var_export( $arr );
// Sort array using primary strength.
collator_set_strength( $coll, Collator::PRIMARY );
collator_sort( $coll, $arr );
var_export( $arr );
?>
以上例程会输出:
array (
0 => 'ao',
1 => 'Ao',
2 => 'aò',
)
array (
0 => 'aò',
1 => 'Ao',
2 => 'ao',
)
参见
- Collator constants
- collator_get_strength
Collator::sortWithSortKeys
collator_sort_with_sort_keys
Sort array using specified collator and sort keys
说明
面向对象风格
public bool
Collator::sortWithSortKeys ( <span
class="methodparam">array &$arr
)
过程化风格
bool <span
class="methodname">collator_sort_with_sort_keys ( <span
class="methodparam">Collator $coll
,
array &$arr
)
Similar to collator_sort but uses ICU sorting keys produced by ucol_getSortKey() to gain more speed on large arrays.
参数
coll
Collator object.
arr
Array of strings to sort
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 <span class="function">collator_sort_with_sort_keys example
<?php
$arr = array( 'Köpfe', 'Kypper', 'Kopfe' );
$coll = collator_create( 'sv' );
collator_sort_with_sort_keys( $coll, $arr );
var_export( $arr );
?>
以上例程会输出:
array (
0 => 'Kopfe',
1 => 'Kypper',
2 => 'Köpfe',
)
参见
- Collator constants
- collator_sort
- collator_asort
Collator::sort
collator_sort
Sort array using specified collator
说明
面向对象风格
public bool
Collator::sort ( <span
class="methodparam">array &$arr
[,
int
$sort_flag
] )
过程化风格
bool <span
class="methodname">collator_sort ( <span
class="methodparam">Collator $coll
,
array &$arr
[, int
$sort_flag
] )
This function sorts an array according to current locale rules.
Equivalent to standard PHP sort .
参数
coll
Collator object.
arr
Array of strings to sort.
sort_flag
Optional sorting type, one of the following:
-
Collator::SORT_REGULAR
- compare items normally (don't change types) -
Collator::SORT_NUMERIC
- compare items numerically -
Collator::SORT_STRING
- compare items as strings
Default sorting type is Collator::SORT_REGULAR
. It is also used if
an invalid sort_flag
value has been specified.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 collator_sort example
<?php
$coll = collator_create( 'en_US' );
$arr = array( 'at', 'às', 'as' );
var_export( $arr );
collator_sort( $coll, $arr );
var_export( $arr );
?>
以上例程会输出:
array (
0 => 'at',
1 => 'às',
2 => 'as',
)array (
0 => 'as',
1 => 'às',
2 => 'at',
)
参见
- Collator constants
- collator_asort
- collator_sort_with_sort_keys
简介
Programs store and operate on numbers using a locale-independent binary representation. When displaying or printing a number it is converted to a locale-specific string. For example, the number 12345.67 is "12,345.67" in the US, "12 345,67" in France and "12.345,67" in Germany.
By invoking the methods provided by the NumberFormatter class, you can format numbers, currencies, and percentages according to the specified or default locale. NumberFormatter is locale-sensitive so you need to create a new NumberFormatter for each locale. NumberFormatter methods format primitive-type numbers, such as double and output the number as a locale-specific string.
For currencies you can use currency format type to create a formatter that returns a string with the formatted number and the appropriate currency sign. Of course, the NumberFormatter class is unaware of exchange rates so, the number output is the same regardless of the specified currency. This means that the same number has different monetary values depending on the currency locale. If the number is 9988776.65 the results will be:
- 9 988 776,65 € in France
- 9.988.776,65 € in Germany
- $9,988,776.65 in the United States
In order to format percentages, create a locale-specific formatter with percentage format type. With this formatter, a decimal fraction such as 0.75 is displayed as 75%.
For more complex formatting, like spelled-out numbers, the rule-based number formatters are used.
类摘要
NumberFormatter
class NumberFormatter {
/* 方法 */
public <span
class="methodname">__construct ( <span
class="methodparam">string $locale
,
int $style
[, string
$pattern
] )
public <span
class="modifier">static NumberFormatter
create ( <span
class="type">string $locale
, <span
class="methodparam">int $style
[,
string
$pattern
] )
public <span
class="type">stringfalse <span
class="methodname">formatCurrency ( <span
class="methodparam">float $value
,
string
$currency
)
public string
format ( <span
class="type">int<span
class="type">float $value
[, <span
class="methodparam">int $type
] )
public int <span
class="methodname">getAttribute ( <span
class="type">int $attr
)
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
public string
getLocale ([ <span
class="methodparam">int $type
] )
public string getPattern ( <span class="methodparam">void )
public string
getSymbol ( <span
class="methodparam">int $attr
)
public string
getTextAttribute ( <span
class="methodparam">int $attr
)
public float
parseCurrency ( <span
class="methodparam">string $value
,
string
&$currency
[, <span
class="type">int &$position
] )
public mixed
parse ( <span
class="type">string $value
[, <span
class="methodparam">int $type
[,
int
&$position
]] )
public bool
setAttribute ( <span
class="methodparam">int $attr
, <span
class="methodparam">int $value
)
public bool
setPattern ( <span
class="methodparam">string $pattern
)
public bool
setSymbol ( <span
class="methodparam">int $attr
, <span
class="methodparam">string $value
)
public bool
setTextAttribute ( <span
class="methodparam">int $attr
, <span
class="methodparam">string $value
)
}
预定义常量
These styles are used by the <span class="function">numfmt_create to define the type of the formatter.
NumberFormatter::PATTERN_DECIMAL
(int)
Decimal format defined by pattern
NumberFormatter::DECIMAL
(int)
Decimal format
NumberFormatter::CURRENCY
(int)
Currency format
NumberFormatter::PERCENT
(int)
Percent format
NumberFormatter::SCIENTIFIC
(int)
Scientific format
NumberFormatter::SPELLOUT
(int)
Spellout rule-based format
NumberFormatter::ORDINAL
(int)
Ordinal rule-based format
NumberFormatter::DURATION
(int)
Duration rule-based format
NumberFormatter::PATTERN_RULEBASED
(int)
Rule-based format defined by pattern
NumberFormatter::CURRENCY_ACCOUNTING
(int)
Currency format for accounting, e.g., ($3.00)
for negative currency amount instead of -$3.00. Available as of PHP
7.4.1 and ICU 53.
NumberFormatter::DEFAULT_STYLE
(int)
Default format for the locale
NumberFormatter::IGNORE
(int)
Alias for PATTERN_DECIMAL
These constants define how the numbers are parsed or formatted. They should be used as arguments to <span class="function">numfmt_format and <span class="function">numfmt_parse.
NumberFormatter::TYPE_DEFAULT
(int)
Derive the type from variable type
NumberFormatter::TYPE_INT32
(int)
Format/parse as 32-bit integer
NumberFormatter::TYPE_INT64
(int)
Format/parse as 64-bit integer
NumberFormatter::TYPE_DOUBLE
(int)
Format/parse as floating point value
NumberFormatter::TYPE_CURRENCY
(int)
Format/parse as currency value
Number format attribute used by <span class="function">numfmt_get_attribute and <span class="function">numfmt_set_attribute.
NumberFormatter::PARSE_INT_ONLY
(int)
Parse integers only.
NumberFormatter::GROUPING_USED
(int)
Use grouping separator.
NumberFormatter::DECIMAL_ALWAYS_SHOWN
(int)
Always show decimal point.
NumberFormatter::MAX_INTEGER_DIGITS
(int)
Maximum integer digits.
NumberFormatter::MIN_INTEGER_DIGITS
(int)
Minimum integer digits.
NumberFormatter::INTEGER_DIGITS
(int)
Integer digits.
NumberFormatter::MAX_FRACTION_DIGITS
(int)
Maximum fraction digits.
NumberFormatter::MIN_FRACTION_DIGITS
(int)
Minimum fraction digits.
NumberFormatter::FRACTION_DIGITS
(int)
Fraction digits.
NumberFormatter::MULTIPLIER
(int)
Multiplier.
NumberFormatter::GROUPING_SIZE
(int)
Grouping size.
NumberFormatter::ROUNDING_MODE
(int)
Rounding Mode.
NumberFormatter::ROUNDING_INCREMENT
(int)
Rounding increment.
NumberFormatter::FORMAT_WIDTH
(int)
The width to which the output of format() is
padded.
NumberFormatter::PADDING_POSITION
(int)
The position at which padding will take place.
See pad position constants for possible argument values.
NumberFormatter::SECONDARY_GROUPING_SIZE
(int)
Secondary grouping size.
NumberFormatter::SIGNIFICANT_DIGITS_USED
(int)
Use significant digits.
NumberFormatter::MIN_SIGNIFICANT_DIGITS
(int)
Minimum significant digits.
NumberFormatter::MAX_SIGNIFICANT_DIGITS
(int)
Maximum significant digits.
NumberFormatter::LENIENT_PARSE
(int)
Lenient parse mode used by rule-based
formats.
Number format text attribute used by <span class="function">numfmt_get_text_attribute and <span class="function">numfmt_set_text_attribute.
NumberFormatter::POSITIVE_PREFIX
(int)
Positive prefix.
NumberFormatter::POSITIVE_SUFFIX
(int)
Positive suffix.
NumberFormatter::NEGATIVE_PREFIX
(int)
Negative prefix.
NumberFormatter::NEGATIVE_SUFFIX
(int)
Negative suffix.
NumberFormatter::PADDING_CHARACTER
(int)
The character used to pad to the format
width.
NumberFormatter::CURRENCY_CODE
(int)
The ISO currency code.
NumberFormatter::DEFAULT_RULESET
(int)
The default rule set. This is only available with
rule-based formatters.
NumberFormatter::PUBLIC_RULESETS
(int)
The public rule sets. This is only available with
rule-based formatters. This is a read-only attribute. The public
rulesets are returned as a single string, with each ruleset name
delimited by ';' (semicolon).
Number format symbols used by <span class="function">numfmt_get_symbol and <span class="function">numfmt_set_symbol.
NumberFormatter::DECIMAL_SEPARATOR_SYMBOL
(int)
The decimal separator.
NumberFormatter::GROUPING_SEPARATOR_SYMBOL
(int)
The grouping separator.
NumberFormatter::PATTERN_SEPARATOR_SYMBOL
(int)
The pattern separator.
NumberFormatter::PERCENT_SYMBOL
(int)
The percent sign.
NumberFormatter::ZERO_DIGIT_SYMBOL
(int)
Zero.
NumberFormatter::DIGIT_SYMBOL
(int)
Character representing a digit in the
pattern.
NumberFormatter::MINUS_SIGN_SYMBOL
(int)
The minus sign.
NumberFormatter::PLUS_SIGN_SYMBOL
(int)
The plus sign.
NumberFormatter::CURRENCY_SYMBOL
(int)
The currency symbol.
NumberFormatter::INTL_CURRENCY_SYMBOL
(int)
The international currency symbol.
NumberFormatter::MONETARY_SEPARATOR_SYMBOL
(int)
The monetary separator.
NumberFormatter::EXPONENTIAL_SYMBOL
(int)
The exponential symbol.
NumberFormatter::PERMILL_SYMBOL
(int)
Per mill symbol.
NumberFormatter::PAD_ESCAPE_SYMBOL
(int)
Escape padding character.
NumberFormatter::INFINITY_SYMBOL
(int)
Infinity symbol.
NumberFormatter::NAN_SYMBOL
(int)
Not-a-number symbol.
NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL
(int)
Significant digit symbol.
NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL
(int)
The monetary grouping separator.
Rounding mode values used by <span
class="function">numfmt_get_attribute and <span
class="function">numfmt_set_attribute with
NumberFormatter::ROUNDING_MODE
attribute.
NumberFormatter::ROUND_CEILING
(int)
Rounding mode to round towards positive
infinity.
NumberFormatter::ROUND_DOWN
(int)
Rounding mode to round towards zero.
NumberFormatter::ROUND_FLOOR
(int)
Rounding mode to round towards negative
infinity.
NumberFormatter::ROUND_HALFDOWN
(int)
Rounding mode to round towards "nearest neighbor"
unless both neighbors are equidistant, in which case round down.
NumberFormatter::ROUND_HALFEVEN
(int)
Rounding mode to round towards the "nearest
neighbor" unless both neighbors are equidistant, in which case, round
towards the even neighbor.
NumberFormatter::ROUND_HALFUP
(int)
Rounding mode to round towards "nearest neighbor"
unless both neighbors are equidistant, in which case round up.
NumberFormatter::ROUND_UP
(int)
Rounding mode to round away from zero.
Pad position values used by <span
class="function">numfmt_get_attribute and <span
class="function">numfmt_set_attribute with
NumberFormatter::PADDING_POSITION
attribute.
NumberFormatter::PAD_AFTER_PREFIX
(int)
Pad characters inserted after the prefix.
NumberFormatter::PAD_AFTER_SUFFIX
(int)
Pad characters inserted after the suffix.
NumberFormatter::PAD_BEFORE_PREFIX
(int)
Pad characters inserted before the prefix.
NumberFormatter::PAD_BEFORE_SUFFIX
(int)
Pad characters inserted before the suffix.
参见
- » ICU formatting documentation
- » ICU number formatters
- » ICU decimal formatters
- » ICU rule-based number formatters
NumberFormatter::create
numfmt_create
NumberFormatter::__construct
Create a number formatter
说明
面向对象风格 (method)
public <span
class="modifier">static NumberFormatter
NumberFormatter::create ( <span
class="methodparam">string $locale
,
int $style
[, string
$pattern
] )
过程化风格
NumberFormatter <span
class="methodname">numfmt_create ( <span
class="methodparam">string $locale
,
int $style
[, string
$pattern
] )
面向对象风格 (constructor):
public <span
class="methodname">NumberFormatter::__construct ( <span
class="methodparam">string $locale
,
int $style
[, string
$pattern
] )
Creates a number formatter.
参数
locale
Locale in which the number would be formatted (locale name, e.g.
en_CA).
style
Style of the formatting, one of the
format style
constants. If NumberFormatter::PATTERN_DECIMAL
or
NumberFormatter::PATTERN_RULEBASED
is passed then the number
format is opened using the given pattern, which must conform to the
syntax described in
» ICU DecimalFormat documentation
or
» ICU RuleBasedNumberFormat documentation,
respectively.
pattern
Pattern string if the chosen style requires a pattern.
返回值
Returns NumberFormatter object or
false
on error.
范例
示例 #1 numfmt_create example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
$fmt = numfmt_create( 'it', NumberFormatter::SPELLOUT );
echo numfmt_format($fmt, 1142)."\n";
?>
示例 #2 NumberFormatter::create example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo $fmt->format(1234567.891234567890000)."\n";
$fmt = new NumberFormatter( 'it', NumberFormatter::SPELLOUT );
echo $fmt->format(1142)."\n";
?>
以上例程会输出:
1.234.567,891
millicentoquarantadue
参见
- numfmt_format
- numfmt_parse
NumberFormatter::formatCurrency
numfmt_format_currency
Format a currency value
说明
面向对象风格
public <span
class="type">stringfalse <span
class="methodname">NumberFormatter::formatCurrency ( <span
class="methodparam">float $value
,
string
$currency
)
过程化风格
string<span
class="type">false <span
class="methodname">numfmt_format_currency ( <span
class="methodparam">NumberFormatter
$fmt
, <span
class="type">float $value
, <span
class="methodparam">string $currency
)
Format the currency value according to the formatter rules.
参数
fmt
NumberFormatter object.
value
The numeric currency value.
currency
The 3-letter ISO 4217 currency code indicating the currency to use.
返回值
String representing the formatted currency value, 或者在失败时返回
false
.
范例
示例 #1 numfmt_format_currency example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::CURRENCY );
echo numfmt_format_currency($fmt, 1234567.891234567890000, "EUR")."\n";
echo numfmt_format_currency($fmt, 1234567.891234567890000, "RUR")."\n";
$fmt = numfmt_create( 'ru_RU', NumberFormatter::CURRENCY );
echo numfmt_format_currency($fmt, 1234567.891234567890000, "EUR")."\n";
echo numfmt_format_currency($fmt, 1234567.891234567890000, "RUR")."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::CURRENCY );
echo $fmt->formatCurrency(1234567.891234567890000, "EUR")."\n";
echo $fmt->formatCurrency(1234567.891234567890000, "RUR")."\n";
$fmt = new NumberFormatter( 'ru_RU', NumberFormatter::CURRENCY );
echo $fmt->formatCurrency(1234567.891234567890000, "EUR")."\n";
echo $fmt->formatCurrency(1234567.891234567890000, "RUR")."\n";
?>
以上例程会输出:
1.234.567,89 €
1.234.567,89 RUR
1 234 567,89€
1 234 567,89р.
参见
- numfmt_get_error_code
- numfmt_format
- numfmt_parse_currency
NumberFormatter::format
numfmt_format
Format a number
说明
面向对象风格
public string
NumberFormatter::format ( <span
class="methodparam"><span
class="type">intfloat
$value
[, <span
class="type">int $type
] )
过程化风格
string <span
class="methodname">numfmt_format ( <span
class="methodparam">NumberFormatter
$fmt
, <span
class="type">intfloat
$value
[, <span
class="type">int $type
] )
Format a numeric value according to the formatter rules.
参数
fmt
NumberFormatter object.
value
The value to format. Can be int or <span
class="type">float, other values will be converted to a numeric
value.
type
The
formatting type
to use.
返回值
Returns the string containing formatted value, or false
on error.
范例
示例 #1 numfmt_format example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
$data = numfmt_format($fmt, 1234567.891234567890000);
if(intl_is_failure(numfmt_format($fmt))) {
report_error("Formatter error");
}
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
$fmt->format(1234567.891234567890000);
if(intl_is_failure($fmt->getErrorCode())) {
report_error("Formatter error");
}
?>
以上例程会输出:
1.234.567,891
参见
- numfmt_get_error_code
- numfmt_format_currency
- numfmt_parse
NumberFormatter::getAttribute
numfmt_get_attribute
Get an attribute
说明
面向对象风格
public int <span
class="methodname">NumberFormatter::getAttribute ( <span
class="methodparam">int $attr
)
过程化风格
int <span
class="methodname">numfmt_get_attribute ( <span
class="methodparam">NumberFormatter
$fmt
, int
$attr
)
Get a numeric attribute associated with the formatter. An example of a numeric attribute is the number of integer digits the formatter will produce.
参数
fmt
NumberFormatter object.
attr
Attribute specifier - one of the
numeric attribute
constants.
返回值
Return attribute value on success, or false
on error.
范例
示例 #1 numfmt_get_attribute example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
numfmt_set_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS, 2);
echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
$fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 2);
echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
?>
以上例程会输出:
Digits: 3
1.234.567,891
Digits: 2
1.234.567,89
参见
- numfmt_get_error_code
- numfmt_get_text_attribute
- numfmt_set_attribute
NumberFormatter::getErrorCode
numfmt_get_error_code
Get formatter's last error code
说明
面向对象风格
public int <span class="methodname">NumberFormatter::getErrorCode ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">numfmt_get_error_code ( <span
class="methodparam">NumberFormatter
$fmt
)
Get error code from the last function performed by the formatter.
参数
fmt
NumberFormatter object.
返回值
Returns error code from last formatter call.
范例
示例 #1 numfmt_get_error_code example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
$data = numfmt_format($fmt, 1234567.891234567890000);
if(intl_is_failure(numfmt_get_error_code($fmt))) {
report_error("Formatter error");
}
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
$fmt->format(1234567.891234567890000);
if(intl_is_failure($fmt->getErrorCode())) {
report_error("Formatter error");
}
?>
参见
- numfmt_get_error_message
- intl_get_error_code
- intl_is_failure
NumberFormatter::getErrorMessage
numfmt_get_error_message
Get formatter's last error message
说明
面向对象风格
public string NumberFormatter::getErrorMessage ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">numfmt_get_error_message ( <span
class="methodparam">NumberFormatter
$fmt
)
Get error message from the last function performed by the formatter.
参数
fmt
NumberFormatter object.
返回值
Returns error message from last formatter call.
范例
示例 #1 numfmt_get_error_message example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
$data = numfmt_format($fmt, 1234567.891234567890000);
var_dump(numfmt_get_error_message($fmt));
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
$fmt->format(1234567.891234567890000);
var_dump(numfmt_get_error_message($fmt));
?>
参见
- numfmt_get_error_code
- intl_get_error_code
- intl_is_failure
NumberFormatter::getLocale
numfmt_get_locale
Get formatter locale
说明
面向对象风格
public string
NumberFormatter::getLocale ([ <span
class="methodparam">int $type
] )
过程化风格
string <span
class="methodname">numfmt_get_locale ( <span
class="methodparam">NumberFormatter
$fmt
[, <span
class="type">int $type
] )
Get formatter locale name.
参数
fmt
NumberFormatter object.
type
You can choose between valid and actual locale (
Locale::VALID_LOCALE
, Locale::ACTUAL_LOCALE
, respectively).
The default is the actual locale.
返回值
The locale name used to create the formatter.
范例
示例 #1 numfmt_get_locale example
<?php
$req = 'fr_FR_PARIS';
$fmt = numfmt_create( $req, NumberFormatter::DECIMAL);
$res_val = numfmt_get_locale( $fmt, Locale::VALID_LOCALE );
$res_act = numfmt_get_locale( $fmt, Locale::ACTUAL_LOCALE );
printf( "Requested locale name: %s\nValid locale name: %s\nActual locale name: %s\n",
$req, $res_val, $res_act );
?>
以上例程会输出:
Requested locale name: fr_FR_PARIS
Valid locale name: fr_FR
Actual locale name: fr
参见
- numfmt_create
- numfmt_get_error_code
NumberFormatter::getPattern
numfmt_get_pattern
Get formatter pattern
说明
面向对象风格
public string NumberFormatter::getPattern ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">numfmt_get_pattern ( <span
class="methodparam">NumberFormatter
$fmt
)
Extract pattern used by the formatter.
参数
fmt
NumberFormatter object.
返回值
Pattern string that is used by the formatter,
or false
if an error happens.
范例
示例 #1 numfmt_get_pattern example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Pattern: ".numfmt_get_pattern($fmt)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
numfmt_set_pattern($fmt, "#0.# kg");
echo "Pattern: ".numfmt_get_pattern($fmt)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Pattern: ".$fmt->getPattern()."\n";
echo $fmt->format(1234567.891234567890000)."\n";
$fmt->setPattern("#0.# kg");
echo "Pattern: ".$fmt->getPattern()."\n";
echo $fmt->format(1234567.891234567890000)."\n";
?>
以上例程会输出:
Pattern: #,##0.###
1.234.567,891
Pattern: #0.# kg
1234567,9 kg
参见
- numfmt_get_error_code
- numfmt_set_pattern
- numfmt_create
NumberFormatter::getSymbol
numfmt_get_symbol
Get a symbol value
说明
面向对象风格
public string
NumberFormatter::getSymbol ( <span
class="methodparam">int $attr
)
过程化风格
string <span
class="methodname">numfmt_get_symbol ( <span
class="methodparam">NumberFormatter
$fmt
, int
$attr
)
Get a symbol associated with the formatter. The formatter uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. This API is not supported for rule-based formatters.
参数
fmt
NumberFormatter object.
attr
Symbol specifier, one of the
format symbol
constants.
返回值
The symbol string or false
on error.
范例
示例 #1 numfmt_get_symbol example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Sep: ".numfmt_get_symbol($fmt, NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
numfmt_set_symbol($fmt, NumberFormatter::GROUPING_SEPARATOR_SYMBOL, "*");
echo "Sep: ".numfmt_get_symbol($fmt, NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
$fmt->setSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL, "*");
echo "Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
?>
以上例程会输出:
Sep: .
1.234.567,891
Sep: *
1*234*567,891
参见
- numfmt_get_error_code
- numfmt_set_symbol
NumberFormatter::getTextAttribute
numfmt_get_text_attribute
Get a text attribute
说明
面向对象风格
public string
NumberFormatter::getTextAttribute (
int $attr
)
过程化风格
string <span
class="methodname">numfmt_get_text_attribute ( <span
class="methodparam">NumberFormatter
$fmt
, int
$attr
)
Get a text attribute associated with the formatter. An example of a text
attribute is the suffix for positive numbers. If the formatter does not
understand the attribute, U_UNSUPPORTED_ERROR
error is produced.
Rule-based formatters only understand
NumberFormatter::DEFAULT_RULESET
and
NumberFormatter::PUBLIC_RULESETS
.
参数
fmt
NumberFormatter object.
attr
Attribute specifier - one of the
text attribute
constants.
返回值
Return attribute value on success, or false
on error.
范例
示例 #1 numfmt_get_text_attribute example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Prefix: ".numfmt_get_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX)."\n";
echo numfmt_format($fmt, -1234567.891234567890000)."\n";
numfmt_set_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX, "MINUS");
echo "Prefix: ".numfmt_get_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX)."\n";
echo numfmt_format($fmt, -1234567.891234567890000)."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo $fmt->format(-1234567.891234567890000)."\n";
$fmt->setTextAttribute(NumberFormatter::NEGATIVE_PREFIX, "MINUS");
echo "Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo $fmt->format(-1234567.891234567890000)."\n";
?>
以上例程会输出:
Prefix: -
-1.234.567,891
Prefix: MINUS
MINUS1.234.567,891
参见
- numfmt_get_error_code
- numfmt_get_attribute
- numfmt_set_text_attribute
NumberFormatter::parseCurrency
numfmt_parse_currency
Parse a currency number
说明
面向对象风格
public float
NumberFormatter::parseCurrency ( <span
class="methodparam">string $value
,
string
&$currency
[, <span
class="type">int &$position
] )
过程化风格
float <span
class="methodname">numfmt_parse_currency ( <span
class="methodparam">NumberFormatter
$fmt
, <span
class="type">string $value
, <span
class="methodparam">string &$currency
[, int
&$position
] )
Parse a string into a double and a currency using the current formatter.
参数
fmt
NumberFormatter object.
currency
Parameter to receive the currency name (3-letter ISO 4217 currency
code).
position
Offset in the string at which to begin parsing. On return, this value
will hold the offset at which parsing ended.
返回值
The parsed numeric value or false
on error.
范例
示例 #1 numfmt_parse_currency example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::CURRENCY );
$num = "1.234.567,89\xc2\xa0$";
echo "We have ".numfmt_parse_currency($fmt, $num, $curr)." in $curr\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::CURRENCY );
$num = "1.234.567,89\xc2\xa0$";
echo "We have ".$fmt->parseCurrency($num, $curr)." in $curr\n";
?>
以上例程会输出:
We have 1234567.89 in USD
参见
- numfmt_get_error_code
- numfmt_parse
- numfmt_format_currency
NumberFormatter::parse
numfmt_parse
Parse a number
说明
面向对象风格
public mixed
NumberFormatter::parse ( <span
class="methodparam">string $value
[,
int $type
[, int
&$position
]] )
过程化风格
mixed <span
class="methodname">numfmt_parse ( <span
class="methodparam">NumberFormatter
$fmt
, <span
class="type">string $value
[, <span
class="methodparam">int $type
[,
int
&$position
]] )
Parse a string into a number using the current formatter rules.
参数
fmt
NumberFormatter object.
type
The
formatting type
to use. By default, NumberFormatter::TYPE_DOUBLE
is used.
position
Offset in the string at which to begin parsing. On return, this value
will hold the offset at which parsing ended.
返回值
The value of the parsed number or false
on error.
范例
示例 #1 numfmt_parse example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
$num = "1.234.567,891";
echo numfmt_parse($fmt, $num)."\n";
echo numfmt_parse($fmt, $num, NumberFormatter::TYPE_INT32)."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
$num = "1.234.567,891";
echo $fmt->parse($num)."\n";
echo $fmt->parse($num, NumberFormatter::TYPE_INT32)."\n";
?>
以上例程会输出:
1234567.891
1234567
参见
- numfmt_get_error_code
- numfmt_format
- numfmt_parse_currency
NumberFormatter::setAttribute
numfmt_set_attribute
Set an attribute
说明
面向对象风格
public bool
NumberFormatter::setAttribute ( <span
class="methodparam">int $attr
, <span
class="methodparam">int $value
)
过程化风格
bool <span
class="methodname">numfmt_set_attribute ( <span
class="methodparam">NumberFormatter
$fmt
, int
$attr
, int
$value
)
Set a numeric attribute associated with the formatter. An example of a numeric attribute is the number of integer digits the formatter will produce.
参数
fmt
NumberFormatter object.
attr
Attribute specifier - one of the
numeric attribute
constants.
value
The attribute value.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 numfmt_set_attribute example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
numfmt_set_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS, 2);
echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
$fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 2);
echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
?>
以上例程会输出:
Digits: 3
1.234.567,891
Digits: 2
1.234.567,89
参见
- numfmt_get_error_code
- numfmt_get_attribute
- numfmt_set_text_attribute
NumberFormatter::setPattern
numfmt_set_pattern
Set formatter pattern
说明
面向对象风格
public bool
NumberFormatter::setPattern ( <span
class="methodparam">string $pattern
)
过程化风格
bool <span
class="methodname">numfmt_set_pattern ( <span
class="methodparam">NumberFormatter
$fmt
, <span
class="type">string $pattern
)
Set the pattern used by the formatter. Can not be used on a rule-based formatter.
参数
fmt
NumberFormatter object.
pattern
Pattern in syntax described in
» ICU DecimalFormat documentation.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 numfmt_set_pattern example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Pattern: ".numfmt_get_pattern($fmt)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
numfmt_set_pattern($fmt, "#0.# kg");
echo "Pattern: ".numfmt_get_pattern($fmt)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Pattern: ".$fmt->getPattern()."\n";
echo $fmt->format(1234567.891234567890000)."\n";
$fmt->setPattern("#0.# kg");
echo "Pattern: ".$fmt->getPattern()."\n";
echo $fmt->format(1234567.891234567890000)."\n";
?>
以上例程会输出:
Pattern: #,##0.###
1.234.567,891
Pattern: #0.# kg
1234567,9 kg
参见
- numfmt_get_error_code
- numfmt_create
- numfmt_get_pattern
NumberFormatter::setSymbol
numfmt_set_symbol
Set a symbol value
说明
面向对象风格
public bool
NumberFormatter::setSymbol ( <span
class="methodparam">int $attr
, <span
class="methodparam">string $value
)
过程化风格
bool <span
class="methodname">numfmt_set_symbol ( <span
class="methodparam">NumberFormatter
$fmt
, int
$attr
, <span
class="type">string $value
)
Set a symbol associated with the formatter. The formatter uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. This API is not supported for rule-based formatters.
参数
fmt
NumberFormatter object.
attr
Symbol specifier, one of the
format symbol
constants.
value
Text for the symbol.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 numfmt_set_symbol example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Sep: ".numfmt_get_symbol($fmt, NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
numfmt_set_symbol($fmt, NumberFormatter::GROUPING_SEPARATOR_SYMBOL, "*");
echo "Sep: ".numfmt_get_symbol($fmt, NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
$fmt->setSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL, "*");
echo "Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
?>
以上例程会输出:
Sep: .
1.234.567,891
Sep: *
1*234*567,891
参见
- numfmt_get_error_code
- numfmt_get_symbol
NumberFormatter::setTextAttribute
numfmt_set_text_attribute
Set a text attribute
说明
面向对象风格
public bool
NumberFormatter::setTextAttribute (
int $attr
,
string
$value
)
过程化风格
bool <span
class="methodname">numfmt_set_text_attribute ( <span
class="methodparam">NumberFormatter
$fmt
, int
$attr
, <span
class="type">string $value
)
Set a text attribute associated with the formatter. An example of a text
attribute is the suffix for positive numbers. If the formatter does not
understand the attribute, U_UNSUPPORTED_ERROR
error is produced.
Rule-based formatters only understand
NumberFormatter::DEFAULT_RULESET
and
NumberFormatter::PUBLIC_RULESETS
.
参数
fmt
NumberFormatter object.
attr
Attribute specifier - one of the
text attribute
constants.
value
Text for the attribute value.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 numfmt_set_text_attribute example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Prefix: ".numfmt_get_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX)."\n";
echo numfmt_format($fmt, -1234567.891234567890000)."\n";
numfmt_set_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX, "MINUS");
echo "Prefix: ".numfmt_get_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX)."\n";
echo numfmt_format($fmt, -1234567.891234567890000)."\n";
?>
示例 #2 OO example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo $fmt->format(-1234567.891234567890000)."\n";
$fmt->setTextAttribute(NumberFormatter::NEGATIVE_PREFIX, "MINUS");
echo "Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo $fmt->format(-1234567.891234567890000)."\n";
?>
以上例程会输出:
Prefix: -
-1.234.567,891
Prefix: MINUS
MINUS1.234.567,891
参见
- numfmt_get_error_code
- numfmt_get_text_attribute
- numfmt_set_attribute
简介
A "Locale" is an identifier used to get language, culture, or regionally-specific behavior from an API. PHP locales are organized and identified the same way that the CLDR locales used by ICU (and many vendors of Unix-like operating systems, the Mac, Java, and so forth) use. Locales are identified using RFC 4646 language tags (which use hyphen, not underscore) in addition to the more traditional underscore-using identifiers. Unless otherwise noted the functions in this class are tolerant of both formats.
Examples of identifiers include:
- en-US (English, United States)
- zh-Hant-TW (Chinese, Traditional Script, Taiwan)
- fr-CA, fr-FR (French for Canada and France respectively)
The Locale class (and related procedural functions) are used to interact with locale identifiers--to verify that an ID is well-formed, valid, etc. The extensions used by CLDR in UAX #35 (and inherited by ICU) are valid and used wherever they would be in ICU normally.
Locales cannot be instantiated as objects. All of the functions/methods provided are static.
The null or empty string obtains the "root" locale. The "root" locale is equivalent to "en_US_POSIX" in CLDR. Language tags (and thus locale identifiers) are case insensitive. There exists a canonicalization function to make case match the specification.
类摘要
Locale
class Locale {
/* 方法 */
public <span
class="modifier">static string <span
class="methodname">acceptFromHttp ( <span
class="methodparam">string $header
)
public <span
class="modifier">static string <span
class="methodname">canonicalize ( <span
class="type">string $locale
)
public <span
class="modifier">static string <span
class="methodname">composeLocale ( <span
class="methodparam">array $subtags
)
public <span
class="modifier">static bool <span
class="methodname">filterMatches ( <span
class="methodparam">string $langtag
,
string
$locale
[, <span
class="type">bool $canonicalize
=
false
] )
public <span
class="modifier">static array <span
class="methodname">getAllVariants ( <span
class="methodparam">string $locale
)
public <span class="modifier">static string <span class="methodname">getDefault ( <span class="methodparam">void )
public <span
class="modifier">static string <span
class="methodname">getDisplayLanguage ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
public <span
class="modifier">static string <span
class="methodname">getDisplayName ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
public <span
class="modifier">static string <span
class="methodname">getDisplayRegion ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
public <span
class="modifier">static string <span
class="methodname">getDisplayScript ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
public <span
class="modifier">static string <span
class="methodname">getDisplayVariant ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
public <span
class="modifier">static array <span
class="methodname">getKeywords ( <span
class="type">string $locale
)
public <span
class="modifier">static string <span
class="methodname">getPrimaryLanguage ( <span
class="methodparam">string $locale
)
public <span
class="modifier">static string <span
class="methodname">getRegion ( <span
class="type">string $locale
)
public <span
class="modifier">static string <span
class="methodname">getScript ( <span
class="type">string $locale
)
public <span
class="modifier">static string <span
class="methodname">lookup ( <span
class="type">array $langtag
, <span
class="methodparam">string $locale
[, bool
$canonicalize
= false
[, string
$default
]] )
public <span
class="modifier">static array <span
class="methodname">parseLocale ( <span
class="type">string $locale
)
public <span
class="modifier">static bool <span
class="methodname">setDefault ( <span
class="type">string $locale
)
}
预定义常量
Locale::DEFAULT_LOCALE
(null)
Used as locale parameter with the methods of the
various locale affected classes, such as NumberFormatter. This constant
would make the methods to use default locale.
These constants describe the choice of the locale for the getLocale method of different classes.
Locale::ACTUAL_LOCALE
(string)
This is locale the data actually comes
from.
Locale::VALID_LOCALE
(string)
This is the most specific locale supported by
ICU.
These constants define how the Locales are parsed or composed. They should be used as keys in the argument array to <span class="function">locale_compose and are returned from <span class="function">locale_parse as keys of the returned associative array.
Locale::LANG_TAG
(string)
Language subtag
Locale::EXTLANG_TAG
(string)
Extended language subtag
Locale::SCRIPT_TAG
(string)
Script subtag
Locale::REGION_TAG
(string)
Region subtag
Locale::VARIANT_TAG
(string)
Variant subtag
Locale::GRANDFATHERED_LANG_TAG
(string)
Grandfathered Language subtag
Locale::PRIVATE_TAG
(string)
Private subtag
参见
- » RFC 4646 - Tags for Identifying Languages
- » RFC 4647 - Matching of Language Tags
- » Unicode CLDR Project:Common Locale Data Repository
- » IANA Language Subtags Registry
- » ICU User Guide - Locale
- » ICU Locale api
Locale::acceptFromHttp
locale_accept_from_http
Tries to find out best available locale based on HTTP "Accept-Language" header
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::acceptFromHttp ( <span
class="methodparam">string $header
)
过程化风格
string <span
class="methodname">locale_accept_from_http ( <span
class="methodparam">string $header
)
Tries to find locale that can satisfy the language list that is requested by the HTTP "Accept-Language" header.
参数
header
The string containing the "Accept-Language" header according to format
in RFC 2616.
返回值
The corresponding locale identifier.
范例
示例 #1 locale_accept_from_http example
<?php
$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo $locale;
?>
示例 #2 OO example
<?php
$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo $locale;
?>
以上例程会输出:
en_US
参见
- locale_lookup
Locale::canonicalize
locale_canonicalize
Canonicalize the locale string
说明
public <span
class="modifier">static string <span
class="methodname">Locale::canonicalize ( <span
class="methodparam">string $locale
)
Warning
本函数还未编写文档,仅有参数列表。
参数
locale
返回值
Locale::composeLocale
locale_compose
Returns a correctly ordered and delimited locale ID
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::composeLocale ( <span
class="methodparam">array $subtags
)
过程化风格
string <span
class="methodname">locale_compose ( <span
class="methodparam">array $subtags
)
Returns a correctly ordered and delimited locale ID the keys identify the particular locale ID subtags, and the values are the associated subtag values.
参数
subtags
an array containing a list of key-value pairs, where the keys identify
the particular locale ID subtags, and the values are the associated
subtag values.
Note:
The 'variant' and 'private' subtags can take maximum 15 values whereas 'extlang' can take maximum 3 values.e.g. Variants are allowed with the suffix ranging from 0-14. Hence the keys for the input array can be variant0, variant1, ...,variant14. In the returned locale id, the subtag is ordered by suffix resulting in variant0 followed by variant1 followed by variant2 and so on.
The 'variant', 'private' and 'extlang' multiple values can be specified both as array under specific key (e.g. 'variant') and as multiple numbered keys (e.g. 'variant0', 'variant1', etc.).
返回值
The corresponding locale identifier.
范例
示例 #1 locale_compose example
<?php
$arr = array(
'language'=>'en' ,
'script' =>'Hans' ,
'region' =>'CN',
'variant2'=>'rozaj' ,
'variant1'=>'nedis' ,
'private1'=>'prv1' ,
'private2'=>'prv2'
);
echo locale_compose( $arr );
?>
示例 #2 OO example
<?php
$arr = array(
'language'=>'en' ,
'script' =>'Hans' ,
'region' =>'CN',
'variant2'=>'rozaj' ,
'variant1'=>'nedis' ,
'private1'=>'prv1' ,
'private2'=>'prv2'
);
echo Locale::composeLocale( $arr );
?>
以上例程会输出:
Locale: en_Hans_CN_nedis_rozaj_x_prv1_prv2
参见
- locale_parse
Locale::filterMatches
locale_filter_matches
Checks if a language tag filter matches with locale
说明
面向对象风格
public <span
class="modifier">static bool <span
class="methodname">Locale::filterMatches ( <span
class="methodparam">string $langtag
,
string
$locale
[, <span
class="type">bool $canonicalize
=
false
] )
过程化风格
bool <span
class="methodname">locale_filter_matches ( <span
class="methodparam">string $langtag
,
string
$locale
[, <span
class="type">bool $canonicalize
=
false
] )
Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm
参数
langtag
The language tag to check
locale
The language range to check against
canonicalize
If true, the arguments will be converted to canonical form before
matching.
返回值
true
if $locale matches $langtag false
otherwise.
范例
示例 #1 locale_filter_matches example
<?php
echo (locale_filter_matches('de-DEVA','de-DE', false)) ? "Matches" : "Does not match";
echo '; ';
echo (locale_filter_matches('de-DE_1996','de-DE', false)) ? "Matches" : "Does not match";
?>
示例 #2 OO example
<?php
echo (Locale::filterMatches('de-DEVA','de-DE', false)) ? "Matches" : "Does not match";
echo '; ';
echo (Locale::filterMatches('de-DE-1996','de-DE', false)) ? "Matches" : "Does not match";
?>
以上例程会输出:
Does not match; Matches
参见
- locale_lookup
Locale::getAllVariants
locale_get_all_variants
Gets the variants for the input locale
说明
面向对象风格
public <span
class="modifier">static array <span
class="methodname">Locale::getAllVariants ( <span
class="methodparam">string $locale
)
过程化风格
array <span
class="methodname">locale_get_all_variants ( <span
class="methodparam">string $locale
)
Gets the variants for the input locale
参数
locale
The locale to extract the variants from
返回值
The array containing the list of all variants
subtag for the locale or null
if not present
范例
示例 #1 locale_get_all_variants example
<?php
$arr = locale_get_all_variants('sl_IT_NEDIS_ROJAZ_1901');
var_export( $arr );
?>
示例 #2 OO example
<?php
$arr = Locale::getAllVariants('sl_IT_NEDIS_ROJAZ_1901');
var_export( $arr );
?>
以上例程会输出:
array (
0 => 'NEDIS',
1 => 'ROJAZ',
2 => '1901',
)
参见
- locale_get_primary_language
- locale_get_script
- locale_get_region
Locale::getDefault
locale_get_default
Gets the default locale value from the INTL global 'default_locale'
说明
面向对象风格
public <span class="modifier">static string <span class="methodname">Locale::getDefault ( <span class="methodparam">void )
过程化风格
string <span class="methodname">locale_get_default ( <span class="methodparam">void )
Gets the default locale value. At the PHP initialization this value is
set to 'intl.default_locale' value from php.ini
if that value exists
or from ICU's function uloc_getDefault().
参数
返回值
The current runtime locale
范例
示例 #1 locale_get_default example
<?php
ini_set('intl.default_locale', 'de-DE');
echo locale_get_default();
echo '; ';
locale_set_default('fr');
echo locale_get_default();
?>
示例 #2 OO example
<?php
ini_set('intl.default_locale', 'de-DE');
echo Locale::getDefault();
echo '; ';
Locale::setDefault('fr');
echo Locale::getDefault();
?>
以上例程会输出:
de-DE; fr
参见
- locale_set_default
Locale::getDisplayLanguage
locale_get_display_language
Returns an appropriately localized display name for language of the inputlocale
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::getDisplayLanguage ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
过程化风格
string <span
class="methodname">locale_get_display_language ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
Returns an appropriately localized display name for language of the
input locale. If is null
then the default locale is used.
参数
locale
The locale to return a display language for
in_locale
Optional format locale to use to display the language name
返回值
display name of the language for the $locale in the format appropriate for $in_locale.
范例
示例 #1 locale_get_display_language example
<?php
echo locale_get_display_language('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo locale_get_display_language('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo locale_get_display_language('sl-Latn-IT-nedis', 'de');
?>
示例 #2 OO example
<?php
echo Locale::getDisplayLanguage('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo Locale::getDisplayLanguage('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo Locale::getDisplayLanguage('sl-Latn-IT-nedis', 'de');
?>
以上例程会输出:
Slovenian;
slov\xc3\xa8ne;
Slowenisch
参见
- locale_get_display_name
- locale_get_display_script
- locale_get_display_region
- locale_get_display_variant
Locale::getDisplayName
locale_get_display_name
Returns an appropriately localized display name for the input locale
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::getDisplayName ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
过程化风格
string <span
class="methodname">locale_get_display_name ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
Returns an appropriately localized display name for the input locale. If
$locale is null
then the default locale is used.
参数
locale
The locale to return a display name for.
in_locale
optional format locale
返回值
Display name of the locale in the format appropriate for $in_locale.
范例
示例 #1 locale_get_display_name example
<?php
echo locale_get_display_name('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo locale_get_display_name('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo locale_get_display_name('sl-Latn-IT-nedis', 'de');
?>
示例 #2 OO example
<?php
echo Locale::getDisplayName('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo Locale::getDisplayName('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo Locale::getDisplayName('sl-Latn-IT-nedis', 'de');
?>
以上例程会输出:
Slovenian (Latin, Italy, Natisone dialect);
slov\xc3\xa8ne (latin, Italie, dialecte de Natisone;
Slowenisch (Lateinisch, Italien, NEDIS)
参见
- locale_get_display_language
- locale_get_display_script
- locale_get_display_region
- locale_get_display_variant
Locale::getDisplayRegion
locale_get_display_region
Returns an appropriately localized display name for region of the input locale
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::getDisplayRegion ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
过程化风格
string <span
class="methodname">locale_get_display_region ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
Returns an appropriately localized display name for region of the input
locale. If is null
then the default locale is used.
参数
locale
The locale to return a display region for.
in_locale
Optional format locale to use to display the region name
返回值
display name of the region for the $locale in the format appropriate for $in_locale.
范例
示例 #1 locale_get_display_region example
<?php
echo locale_get_display_region('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo locale_get_display_region('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo locale_get_display_region('sl-Latn-IT-nedis', 'de');
?>
示例 #2 OO example
<?php
echo Locale::getDisplayRegion('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo Locale::getDisplayRegion('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo Locale::getDisplayRegion('sl-Latn-IT-nedis', 'de');
?>
以上例程会输出:
Italy;
Italie;
Italien
参见
- locale_get_display_name
- locale_get_display_language
- locale_get_display_script
- locale_get_display_variant
Locale::getDisplayScript
locale_get_display_script
Returns an appropriately localized display name for script of the input locale
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::getDisplayScript ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
过程化风格
string <span
class="methodname">locale_get_display_script ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
Returns an appropriately localized display name for script of the input
locale. If is null
then the default locale is used.
参数
locale
The locale to return a display script for
in_locale
Optional format locale to use to display the script name
返回值
Display name of the script for the $locale in the format appropriate for $in_locale.
范例
示例 #1 locale_get_display_script example
<?php
echo locale_get_display_script('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo locale_get_display_script('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo locale_get_display_script('sl-Latn-IT-nedis', 'de');
?>
示例 #2 OO example
<?php
echo Locale::getDisplayScript('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo Locale::getDisplayScript('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo Locale::getDisplayScript('sl-Latn-IT-nedis', 'de');
?>
以上例程会输出:
Latin;
latin;
Lateinisch
参见
- locale_get_display_name
- locale_get_display_language
- locale_get_display_region
- locale_get_display_variant
Locale::getDisplayVariant
locale_get_display_variant
Returns an appropriately localized display name for variants of the input locale
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::getDisplayVariant ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
过程化风格
string <span
class="methodname">locale_get_display_variant ( <span
class="methodparam">string $locale
[, string
$in_locale
] )
Returns an appropriately localized display name for variants of the
input locale. If is null
then the default locale is used.
参数
locale
The locale to return a display variant for
in_locale
Optional format locale to use to display the variant name
返回值
Display name of the variant for the $locale in the format appropriate for $in_locale.
范例
示例 #1 locale_get_display_variant example
<?php
echo locale_get_display_variant('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo locale_get_display_variant('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo locale_get_display_variant('sl-Latn-IT-nedis', 'de');
?>
示例 #2 OO example
<?php
echo Locale::getDisplayVariant('sl-Latn-IT-nedis', 'en');
echo ";\n";
echo Locale::getDisplayVariant('sl-Latn-IT-nedis', 'fr');
echo ";\n";
echo Locale::getDisplayVariant('sl-Latn-IT-nedis', 'de');
?>
以上例程会输出:
Natisone dialect;
dialecte de Natisone;
NEDIS
参见
- locale_get_display_name
- locale_get_display_language
- locale_get_display_script
- locale_get_display_region
Locale::getKeywords
locale_get_keywords
Gets the keywords for the input locale
说明
面向对象风格
public <span
class="modifier">static array <span
class="methodname">Locale::getKeywords ( <span
class="methodparam">string $locale
)
过程化风格
array <span
class="methodname">locale_get_keywords ( <span
class="methodparam">string $locale
)
Gets the keywords for the input locale.
参数
locale
The locale to extract the keywords from
返回值
Associative array containing the keyword-value pairs for this locale
范例
示例 #1 locale_get_keywords example
<?php
$keywords_arr = locale_get_keywords('de_DE@currency=EUR;collation=PHONEBOOK');
if ($keywords_arr) {
foreach ($keywords_arr as $key => $value) {
echo "$key = $value\n";
}
}
?>
示例 #2 OO example
<?php
$keywords_arr = Locale::getKeywords('de_DE@currency=EUR;collation=PHONEBOOK');
if ($keywords_arr) {
foreach ($keywords_arr as $key => $value) {
echo "$key = $value\n";
}
}
?>
以上例程会输出:
collation = PHONEBOOK
currency = EUR
参见
- locale_get_all_variants
Locale::getPrimaryLanguage
locale_get_primary_language
Gets the primary language for the input locale
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::getPrimaryLanguage ( <span
class="methodparam">string $locale
)
过程化风格
string <span
class="methodname">locale_get_primary_language ( <span
class="methodparam">string $locale
)
Gets the primary language for the input locale
参数
locale
The locale to extract the primary language code from
返回值
The language code associated with the language or null
in case of
error.
范例
示例 #1 locale_get_primary_language example
<?php
echo locale_get_primary_language('zh-Hant');
?>
示例 #2 OO example
<?php
echo Locale::getPrimaryLanguage('zh-Hant');
?>
以上例程会输出:
zh
参见
- locale_get_script
- locale_get_region
- locale_get_all_variants
Locale::getRegion
locale_get_region
Gets the region for the input locale
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::getRegion ( <span
class="methodparam">string $locale
)
过程化风格
string <span
class="methodname">locale_get_region ( <span
class="methodparam">string $locale
)
Gets the region for the input locale.
参数
locale
The locale to extract the region code from
返回值
The region subtag for the locale or null
if not present
范例
示例 #1 locale_get_region example
<?php
echo locale_get_region('de-CH-1901');
?>
示例 #2 OO example
<?php
echo Locale::getRegion('de-CH-1901');
?>
以上例程会输出:
CH
参见
- locale_get_primary_language
- locale_get_script
- locale_get_all_variants
Locale::getScript
locale_get_script
Gets the script for the input locale
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::getScript ( <span
class="methodparam">string $locale
)
过程化风格
string <span
class="methodname">locale_get_script ( <span
class="methodparam">string $locale
)
Gets the script for the input locale.
参数
locale
The locale to extract the script code from
返回值
The script subtag for the locale or null
if not present
范例
示例 #1 locale_get_script example
<?php
echo locale_get_script('sr-Cyrl');
?>
示例 #2 OO example
<?php
echo Locale::getScript('sr-Cyrl');
?>
以上例程会输出:
Cyrl
参见
- locale_get_primary_language
- locale_get_region
- locale_get_all_variants
Locale::lookup
locale_lookup
Searches the language tag list for the best match to the language
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Locale::lookup ( <span
class="methodparam">array $langtag
,
string
$locale
[, <span
class="type">bool $canonicalize
=
false
[, <span
class="type">string $default
]] )
过程化风格
string <span
class="methodname">locale_lookup ( <span
class="methodparam">array $langtag
,
string
$locale
[, <span
class="type">bool $canonicalize
=
false
[, <span
class="type">string $default
]] )
Searches the items in langtag
for the best match to the language range
specified in locale
according to RFC 4647's lookup algorithm.
参数
langtag
An array containing a list of language tags to
compare to locale
. Maximum 100 items allowed.
locale
The locale to use as the language range when matching.
canonicalize
If true, the arguments will be converted to canonical form before
matching.
default
The locale to use if no match is found.
返回值
The closest matching language tag or default value.
范例
示例 #1 locale_lookup example
<?php
$arr = array(
'de-DEVA',
'de-DE-1996',
'de',
'de-De'
);
echo locale_lookup($arr, 'de-DE-1996-x-prv1-prv2', true, 'en_US');
?>
示例 #2 OO example
<?php
$arr = array(
'de-DEVA',
'de-DE-1996',
'de',
'de-De'
);
echo Locale::lookup($arr, 'de-DE-1996-x-prv1-prv2', true, 'en_US');
?>
以上例程会输出:
de_de_1996
参见
- locale_filter_matches
Locale::parseLocale
locale_parse
Returns a key-value array of locale ID subtag elements
说明
面向对象风格
public <span
class="modifier">static array <span
class="methodname">Locale::parseLocale ( <span
class="methodparam">string $locale
)
过程化风格
array <span
class="methodname">locale_parse ( <span
class="methodparam">string $locale
)
Returns a key-value array of locale ID subtag elements.
参数
locale
The locale to extract the subtag array from. Note: The 'variant' and
'private' subtags can take maximum 15 values whereas 'extlang' can take
maximum 3 values.
返回值
Returns an array containing a list of key-value pairs, where the keys identify the particular locale ID subtags, and the values are the associated subtag values. The array will be ordered as the locale id subtags e.g. in the locale id if variants are '-varX-varY-varZ' then the returned array will have variant0=>varX , variant1=>varY , variant2=>varZ
Returns null
when the length of locale
exceeds
INTL_MAX_LOCALE_LEN
.
范例
示例 #1 locale_parse example
<?php
$arr = locale_parse('sl-Latn-IT-nedis');
if ($arr) {
foreach ($arr as $key => $value) {
echo "$key : $value , ";
}
}
?>
示例 #2 OO example
<?php
$arr = Locale::parseLocale('sl-Latn-IT-nedis');
if ($arr) {
foreach ($arr as $key => $value) {
echo "$key : $value , ";
}
}
?>
以上例程会输出:
language : sl , script : Latn , region : IT , variant0 : NEDIS ,
参见
- locale_compose
Locale::setDefault
locale_set_default
Sets the default runtime locale
说明
面向对象风格
public <span
class="modifier">static bool <span
class="methodname">Locale::setDefault ( <span
class="methodparam">string $locale
)
过程化风格
bool <span
class="methodname">locale_set_default ( <span
class="methodparam">string $locale
)
Sets the default runtime locale to $locale. This changes the value of INTL global 'default_locale' locale identifier. UAX #35 extensions are accepted.
参数
locale
Is a BCP 47 compliant language tag.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 locale_set_default example
<?php
locale_set_default('de-DE');
echo locale_get_default();
?>
示例 #2 OO example
<?php
Locale::setDefault('de-DE');
echo Locale::getDefault();
?>
以上例程会输出:
de-DE
参见
- locale_get_default
简介
Normalization is a process that involves transforming characters and sequences of characters into a formally-defined underlying representation. This process is most important when text needs to be compared for sorting and searching, but it is also used when storing text to ensure that the text is stored in a consistent representation.
The Unicode Consortium has defined a number of normalization forms reflecting the various needs of applications:
- Normalization Form D (NFD) - Canonical Decomposition
- Normalization Form C (NFC) - Canonical Decomposition followed by Canonical Composition
- Normalization Form KD (NFKD) - Compatibility Decomposition
- Normalization Form KC (NFKC) - Compatibility Decomposition followed by Canonical Composition
The different forms are defined in terms of a set of transformations on the text, transformations that are expressed by both an algorithm and a set of data files.
类摘要
Normalizer
class Normalizer {
/* 方法 */
public <span
class="modifier">static string <span
class="methodname">getRawDecomposition ( <span
class="methodparam">string $input
)
public <span
class="modifier">static bool <span
class="methodname">isNormalized ( <span
class="type">string $input
[, <span
class="methodparam">int $form
<span
class="initializer"> = Normalizer::FORM_C ] )
public <span
class="modifier">static string <span
class="methodname">normalize ( <span
class="type">string $input
[, <span
class="methodparam">int $form
<span
class="initializer"> = Normalizer::FORM_C ] )
}
预定义常量
The following constants define the normalization form used by the normalizer:
Normalizer::FORM_C
(int)
Normalization Form C (NFC) - Canonical
Decomposition followed by Canonical Composition
Normalizer::FORM_D
(int)
Normalization Form D (NFD) - Canonical
Decomposition
Normalizer::FORM_KC
(int)
Normalization Form KC (NFKC) - Compatibility
Decomposition, followed by Canonical Composition
Normalizer::FORM_KD
(int)
Normalization Form KD (NFKD) - Compatibility
Decomposition
Normalizer::NONE
(int)
No decomposition/composition
Normalizer::OPTION_DEFAULT
(int)
Default normalization options
参见
- » Unicode Normalization
- » Unicode Normalization FAQ
- » ICU User Guide - Normalization
- » ICU API Reference - Normalization
Normalizer::getRawDecomposition
normalizer_get_raw_decomposition
Gets the Decomposition_Mapping property for the given UTF-8 encoded code point
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Normalizer::getRawDecomposition ( <span
class="methodparam">string $input
)
过程化风格
string <span
class="methodname">normalizer_get_raw_decomposition ( <span
class="methodparam">string $input
)
Gets the Decomposition_Mapping property, as specified in the Unicode Character Database (UCD), for the given UTF-8 encoded code point.
参数
input
The input string, which should be a single, UTF-8 encoded, code point.
返回值
Returns a string containing the Decomposition_Mapping property, if present in the UCD.
Returns null
if there is no Decomposition_Mapping property for
the character.
范例
示例 #1 <span class="methodname">Normalizer::getRawDecomposition example
<?php
$result = "";
$strings = [
"a",
"\u{FFDA}",
"\u{FDFA}",
"",
"aa",
"\xF5",
];
foreach ($strings as $string) {
$decomposition = Normalizer::getRawDecomposition($string);
// $decomposition = normalizer_get_raw_decomposition($string); Procedural way
$error_code = intl_get_error_code();
$error_message = intl_get_error_message();
$string_hex = bin2hex($string);
$result .= "---------------------\n";
if ($decomposition === null) {
$result .= "'$string_hex' has no decomposition mapping\n" ;
} else {
$result .= "'$string_hex' has the decomposition mapping '" . bin2hex($decomposition) . "'\n" ;
}
$result .= "error info: '$error_message' ($error_code)\n";
}
echo $result;
?>
以上例程会输出:
---------------------
'61' has no decomposition mapping
error info: 'U_ZERO_ERROR' (0)
---------------------
'efbf9a' has the decomposition mapping 'e385a1'
error info: 'U_ZERO_ERROR' (0)
---------------------
'efb7ba' has the decomposition mapping 'd8b5d984d98920d8a7d984d984d98720d8b9d984d98ad98720d988d8b3d984d985'
error info: 'U_ZERO_ERROR' (0)
---------------------
'' has no decomposition mapping
error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1)
---------------------
'6161' has no decomposition mapping
error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1)
---------------------
'f5' has no decomposition mapping
error info: 'Code point out of range: U_ILLEGAL_ARGUMENT_ERROR' (1)
参见
- Normalizer::normalize
- Normalizer::isNormalized
Normalizer::isNormalized
normalizer_is_normalized
Checks if the provided string is already in the specified normalization form
说明
面向对象风格
public <span
class="modifier">static bool <span
class="methodname">Normalizer::isNormalized ( <span
class="methodparam">string $input
[,
int $form
<span
class="initializer"> = Normalizer::FORM_C ] )
过程化风格
bool <span
class="methodname">normalizer_is_normalized ( <span
class="methodparam">string $input
[,
int $form
<span
class="initializer"> = Normalizer::FORM_C ] )
Checks if the provided string is already in the specified normalization form.
参数
input
The input string to normalize
form
One of the normalization forms.
返回值
true
if normalized, false
otherwise or if there an error
范例
示例 #1 normalizer_is_normalized example
<?php
$char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
$char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A)
$char_orig = 'A' . $char_combining_ring_above;
$char_norm = normalizer_normalize( 'A' . $char_combining_ring_above, Normalizer::FORM_C );
echo ( normalizer_is_normalized($char_orig, Normalizer::FORM_C) ) ? "normalized" : "not normalized";
echo '; ';
echo ( normalizer_is_normalized($char_norm, Normalizer::FORM_C) ) ? "normalized" : "not normalized";
?>
示例 #2 OO example
<?php
$char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
$char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A)
$char_orig = 'A' . $char_combining_ring_above;
$char_norm = Normalizer::normalize( 'A' . $char_combining_ring_above, Normalizer::FORM_C );
echo ( Normalizer::isNormalized($char_orig, Normalizer::FORM_C) ) ? "normalized" : "not normalized";
echo '; ';
echo ( Normalizer::isNormalized($char_norm, Normalizer::FORM_C) ) ? "normalized" : "not normalized";
?>
以上例程会输出:
not normalized; normalized
参见
- normalizer_normalize
Normalizer::normalize
normalizer_normalize
Normalizes the input provided and returns the normalized string
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">Normalizer::normalize ( <span
class="methodparam">string $input
[,
int $form
<span
class="initializer"> = Normalizer::FORM_C ] )
过程化风格
string <span
class="methodname">normalizer_normalize ( <span
class="methodparam">string $input
[,
int $form
<span
class="initializer"> = Normalizer::FORM_C ] )
Normalizes the input provided and returns the normalized string
参数
input
The input string to normalize
form
One of the normalization forms.
返回值
The normalized string or false
if an error occurred.
范例
示例 #1 normalizer_normalize example
<?php
$char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
$char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A)
$char_1 = normalizer_normalize( $char_A_ring, Normalizer::FORM_C );
$char_2 = normalizer_normalize( 'A' . $char_combining_ring_above, Normalizer::FORM_C );
echo urlencode($char_1);
echo ' ';
echo urlencode($char_2);
?>
示例 #2 OO example
<?php
$char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
$char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A)
$char_1 = Normalizer::normalize( $char_A_ring, Normalizer::FORM_C );
$char_2 = Normalizer::normalize( 'A' . $char_combining_ring_above, Normalizer::FORM_C );
echo urlencode($char_1);
echo ' ';
echo urlencode($char_2);
?>
以上例程会输出:
%C3%85 %C3%85
参见
- normalizer_is_normalized
简介
MessageFormatter is a concrete class that enables users to produce concatenated, language-neutral messages. The methods supplied in this class are used to build all the messages that are seen by end users.
The MessageFormatter class assembles messages from various fragments (such as text fragments, numbers, and dates) supplied by the program. Because of the MessageFormatter class, the program does not need to know the order of the fragments. The class uses the formatting specifications for the fragments to assemble them into a message that is contained in a single string within a resource bundle. For example, MessageFormatter enables you to print the phrase "Finished printing x out of y files..." in a manner that still allows for flexibility in translation.
Previously, an end user message was created as a sentence and handled as a string. This procedure created problems for localizers because the sentence structure, word order, number format and so on are very different from language to language. The language-neutral way to create messages keeps each part of the message separate and provides keys to the data. Using these keys, the MessageFormatter class can concatenate the parts of the message, localize them, and display a well-formed string to the end user.
MessageFormatter takes a set of objects, formats them, and then inserts the formatted strings into the pattern at the appropriate places. Choice formats can be used in conjunction with MessageFormatter to handle plurals, match numbers, and select from an array of items. Typically, the message format will come from resources and the arguments will be dynamically set at runtime.
类摘要
MessageFormatter
class MessageFormatter {
/* 方法 */
public <span
class="methodname">__construct ( <span
class="methodparam">string $locale
,
string
$pattern
)
public <span
class="modifier">static <span
class="type">MessageFormatter <span
class="methodname">create ( <span
class="type">string $locale
, <span
class="methodparam">string $pattern
)
public <span
class="modifier">static string <span
class="methodname">formatMessage ( <span
class="methodparam">string $locale
,
string
$pattern
, <span
class="type">array $args
)
public string
format ( <span
class="type">array $args
)
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
public string getLocale ( <span class="methodparam">void )
public string getPattern ( <span class="methodparam">void )
public <span
class="modifier">static array <span
class="methodname">parseMessage ( <span
class="type">string $locale
, <span
class="methodparam">string $pattern
,
string
$source
)
public array
parse ( <span
class="type">string $value
)
public bool
setPattern ( <span
class="methodparam">string $pattern
)
}
参见
- » ICU formatting documentation
- » ICU message formatting description
- » ICU message formatters
- » ICU choice formatters
MessageFormatter::create
MessageFormatter::__construct
msgfmt_create
Constructs a new Message Formatter
说明
面向对象风格 (method)
public <span
class="modifier">static <span
class="type">MessageFormatter <span
class="methodname">MessageFormatter::create ( <span
class="methodparam">string $locale
,
string
$pattern
)
面向对象风格 (constructor):
public <span
class="methodname">MessageFormatter::__construct ( <span
class="methodparam">string $locale
,
string
$pattern
)
过程化风格
MessageFormatter <span
class="methodname">msgfmt_create ( <span
class="methodparam">string $locale
,
string
$pattern
)
Constructs a new Message Formatter
参数
locale
The locale to use when formatting arguments
pattern
The pattern string to stick arguments into. The pattern uses an
'apostrophe-friendly' syntax; it is run through
» umsg_autoQuoteApostrophe
before being interpreted.
返回值
The formatter object
错误/异常
When invoked as constructor, on failure an <span class="classname">IntlException is thrown.
范例
示例 #1 msgfmt_create example
<?php
$fmt = msgfmt_create("en_US", "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
echo msgfmt_format($fmt, array(4560, 123, 4560/123));
$fmt = msgfmt_create("de", "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
echo msgfmt_format($fmt, array(4560, 123, 4560/123));
?>
示例 #2 OO example
<?php
$fmt = new MessageFormatter("en_US", "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
echo $fmt->format(array(4560, 123, 4560/123));
$fmt = new MessageFormatter("de", "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
echo $fmt->format(array(4560, 123, 4560/123));
?>
以上例程会输出:
4,560 monkeys on 123 trees make 37.073 monkeys per tree
4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum
参见
- msgfmt_format
- msgfmt_parse
- msgfmt_get_error_code
- msgfmt_get_error_message
MessageFormatter::formatMessage
msgfmt_format_message
Quick format message
说明
面向对象风格
public <span
class="modifier">static string <span
class="methodname">MessageFormatter::formatMessage ( <span
class="methodparam">string $locale
,
string
$pattern
, <span
class="type">array $args
)
过程化风格
string <span
class="methodname">msgfmt_format_message ( <span
class="methodparam">string $locale
,
string
$pattern
, <span
class="type">array $args
)
Quick formatting function that formats the string without having to explicitly create the formatter object. Use this function when the format operation is done only once and does not need and parameters or state to be kept.
参数
locale
The locale to use for formatting locale-dependent parts
pattern
The pattern string to insert things into. The
pattern uses an 'apostrophe-friendly' syntax; it is run through
» umsg_autoQuoteApostrophe
before being interpreted.
args
The array of values to insert into the format
string
返回值
The formatted pattern string or false
if an error occurred
范例
示例 #1 msgfmt_format_message example
<?php
echo msgfmt_format_message("en_US", "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree\n", array(4560, 123, 4560/123));
echo msgfmt_format_message("de", "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum\n", array(4560, 123, 4560/123));
?>
示例 #2 OO example
<?php
echo MessageFormatter::formatMessage("en_US", "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree\n", array(4560, 123, 4560/123));
echo MessageFormatter::formatMessage("de", "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum\n", array(4560, 123, 4560/123));
?>
以上例程会输出:
4,560 monkeys on 123 trees make 37.073 monkeys per tree
4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum
参见
- msgfmt_create
- msgfmt_parse
- msgfmt_get_error_code
- msgfmt_get_error_message
MessageFormatter::format
msgfmt_format
Format the message
说明
面向对象风格
public string
MessageFormatter::format ( <span
class="methodparam">array $args
)
过程化风格
string <span
class="methodname">msgfmt_format ( <span
class="methodparam">MessageFormatter
$fmt
, <span
class="type">array $args
)
Format the message by substituting the data into the format string according to the locale rules
参数
fmt
The message formatter
args
Arguments to insert into the format string
返回值
The formatted string, or false
if an error occurred
范例
示例 #1 msgfmt_format example
<?php
$fmt = msgfmt_create("en_US", "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
echo msgfmt_format($fmt, array(4560, 123, 4560/123));
$fmt = msgfmt_create("de", "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
echo msgfmt_format($fmt, array(4560, 123, 4560/123));
?>
示例 #2 OO example
<?php
$fmt = new MessageFormatter("en_US", "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
echo $fmt->format(array(4560, 123, 4560/123));
$fmt = new MessageFormatter("de", "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
echo $fmt->format(array(4560, 123, 4560/123));
?>
以上例程会输出:
4,560 monkeys on 123 trees make 37.073 monkeys per tree
4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum
参见
- msgfmt_create
- msgfmt_parse
- msgfmt_format_message
- msgfmt_get_error_code
- msgfmt_get_error_message
MessageFormatter::getErrorCode
msgfmt_get_error_code
Get the error code from last operation
说明
面向对象风格
public int <span class="methodname">MessageFormatter::getErrorCode ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">msgfmt_get_error_code ( <span
class="methodparam">MessageFormatter
$fmt
)
Get the error code from last operation.
参数
fmt
The message formatter
返回值
The error code, one of UErrorCode values. Initial value is U_ZERO_ERROR.
参见
- msgfmt_get_error_message
- intl_get_error_code
- intl_is_failure
MessageFormatter::getErrorMessage
msgfmt_get_error_message
Get the error text from the last operation
说明
面向对象风格
public string MessageFormatter::getErrorMessage ( void )
过程化风格
string <span
class="methodname">msgfmt_get_error_message ( <span
class="methodparam">MessageFormatter
$fmt
)
Get the error text from the last operation.
参数
fmt
The message formatter
返回值
Description of the last error.
范例
示例 #1 msgfmt_get_error_message example
<?php
$fmt = msgfmt_create("en_US", "{0, number} monkeys on {1, number} trees");
$str = msgfmt_format($fmt, array());
if(!$str) {
echo "ERROR: ".msgfmt_get_error_message($fmt) . " (" . msgfmt_get_error_code($fmt) . ")\n";
}
?>
示例 #2 OO example
<?php
$fmt = new MessageFormatter("en_US", "{0, number} monkeys on {1, number} trees");
$str = $fmt->format(array());
if(!$str) {
echo "ERROR: ".$fmt->getErrorMessage() . " (" . $fmt->getErrorCode() . ")\n";
}
?>
以上例程会输出:
ERROR: msgfmt_format: not enough parameters: U_ILLEGAL_ARGUMENT_ERROR (1)
参见
- msgfmt_get_error_code
- intl_get_error_code
- intl_is_failure
MessageFormatter::getLocale
msgfmt_get_locale
Get the locale for which the formatter was created
说明
面向对象风格
public string MessageFormatter::getLocale ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">msgfmt_get_locale ( <span
class="methodparam">NumberFormatter
$formatter
)
Get the locale for which the formatter was created.
参数
formatter
The formatter resource
返回值
The locale name
范例
示例 #1 msgfmt_get_locale example
<?php
$fmt = msgfmt_create('en_US', "Number {0,number}");
echo msgfmt_get_locale($fmt);
?>
示例 #2 OO example
<?php
$fmt = new MessageFormatter('en_US', "Number {0,number}");
echo $fmt->getLocale();
?>
以上例程会输出:
en_US
参见
- msgfmt_create
MessageFormatter::getPattern
msgfmt_get_pattern
Get the pattern used by the formatter
说明
面向对象风格
public string MessageFormatter::getPattern ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">msgfmt_get_pattern ( <span
class="methodparam">MessageFormatter
$fmt
)
Get the pattern used by the formatter
参数
fmt
The message formatter
返回值
The pattern string for this message formatter
范例
示例 #1 msgfmt_get_pattern example
<?php
$fmt = msgfmt_create( "en_US", "{0, number} monkeys on {1, number} trees" );
echo "Default pattern: '" . msgfmt_get_pattern( $fmt ) . "'\n";
echo "Formatting result: " . msgfmt_format( $fmt, array(123, 456) ) . "\n";
msgfmt_set_pattern( $fmt, "{0, number} trees hosting {1, number} monkeys" );
echo "New pattern: '" . msgfmt_get_pattern( $fmt ) . "'\n";
echo "Formatted number: " . msgfmt_format( $fmt, array(123, 456) ) . "\n";
?>
示例 #2 OO example
<?php
$fmt = new MessageFormatter( "en_US", "{0, number} monkeys on {1, number} trees" );
echo "Default pattern: '" . $fmt->getPattern() . "'\n";
echo "Formatting result: " . $fmt->format(array(123, 456)) . "\n";
$fmt->setPattern("{0, number} trees hosting {1, number} monkeys" );
echo "New pattern: '" . $fmt->getPattern() . "'\n";
echo "Formatted number: " . $fmt->format(array(123, 456)) . "\n";
?>
以上例程会输出:
Default pattern: '{0,number} monkeys on {1,number} trees'
Formatting result: 123 monkeys on 456 trees
New pattern: '{0,number} trees hosting {1,number} monkeys'
Formatted number: 123 trees hosting 456 monkeys
参见
- msgfmt_create
- msgfmt_set_pattern
MessageFormatter::parseMessage
msgfmt_parse_message
Quick parse input string
说明
面向对象风格
public <span
class="modifier">static array <span
class="methodname">MessageFormatter::parseMessage ( <span
class="methodparam">string $locale
,
string
$pattern
, <span
class="type">string $source
)
过程化风格
array <span
class="methodname">msgfmt_parse_message ( <span
class="methodparam">string $locale
,
string
$pattern
, <span
class="type">string $value
)
Parses input string without explicitly creating the formatter object. Use this function when the format operation is done only once and does not need and parameters or state to be kept.
参数
locale
The locale to use for parsing locale-dependent parts
pattern
The pattern with which to parse the value
.
source
The string to parse, conforming to the
pattern
.
返回值
An array containing items extracted, or
false
on error
范例
示例 #1 msgfmt_parse_message example
<?php
$fmt = msgfmt_parse_message('en_US', "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree",
"4,560 monkeys on 123 trees make 37.073 monkeys per tree");
var_export($fmt);
$fmt = msgfmt_parse_message('de', "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum",
"4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum");
var_export($fmt);
?>
示例 #2 OO example
<?php
$fmt = MessageFormatter::parseMessage('en_US', "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree",
"4,560 monkeys on 123 trees make 37.073 monkeys per tree");
var_export($fmt);
$fmt = MessageFormatter::parseMessage('de', "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum",
"4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum");
var_export($fmt);
?>
以上例程会输出:
array (
0 => 4560,
1 => 123,
2 => 37.073,
)
array (
0 => 4560,
1 => 123,
2 => 37.073,
)
参见
- msgfmt_create
- msgfmt_format_message
- msgfmt_parse
MessageFormatter::parse
msgfmt_parse
Parse input string according to pattern
说明
面向对象风格
public array
MessageFormatter::parse ( <span
class="methodparam">string $value
)
过程化风格
array <span
class="methodname">msgfmt_parse ( <span
class="methodparam">MessageFormatter
$fmt
, <span
class="type">string $value
)
Parses input string and return any extracted items as an array.
参数
fmt
The message formatter
value
The string to parse
返回值
An array containing the items extracted, or
false
on error
范例
示例 #1 msgfmt_parse example
<?php
$fmt = msgfmt_create('en_US', "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
$res = msgfmt_parse($fmt, "4,560 monkeys on 123 trees make 37.073 monkeys per tree");
var_export($res);
$fmt = msgfmt_create('de', "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
$res = msgfmt_parse($fmt, "4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum");
var_export($res);
?>
示例 #2 OO example
<?php
$fmt = new MessageFormatter('en_US', "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
$res = $fmt->parse("4,560 monkeys on 123 trees make 37.073 monkeys per tree");
var_export($res);
$fmt = new MessageFormatter('de', "{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
$res = $fmt->parse("4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum");
var_export($res);
?>
以上例程会输出:
array (
0 => 4560,
1 => 123,
2 => 37.073,
)
array (
0 => 4560,
1 => 123,
2 => 37.073,
)
参见
- msgfmt_create
- msgfmt_format
- msgfmt_parse_message
MessageFormatter::setPattern
msgfmt_set_pattern
Set the pattern used by the formatter
说明
面向对象风格
public bool
MessageFormatter::setPattern ( <span
class="methodparam">string $pattern
)
过程化风格
bool <span
class="methodname">msgfmt_set_pattern ( <span
class="methodparam">MessageFormatter
$fmt
, <span
class="type">string $pattern
)
Set the pattern used by the formatter
参数
fmt
The message formatter
pattern
The pattern string to use in this message
formatter. The pattern uses an 'apostrophe-friendly' syntax; it is run
through
» umsg_autoQuoteApostrophe
before being interpreted.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 msgfmt_set_pattern example
<?php
$fmt = msgfmt_create( "en_US", "{0, number} monkeys on {1, number} trees" );
echo "Default pattern: '" . msgfmt_get_pattern( $fmt ) . "'\n";
echo "Formatting result: " . msgfmt_format( $fmt, array(123, 456) ) . "\n";
msgfmt_set_pattern( $fmt, "{0, number} trees hosting {1, number} monkeys" );
echo "New pattern: '" . msgfmt_get_pattern( $fmt ) . "'\n";
echo "Formatted number: " . msgfmt_format( $fmt, array(123, 456) ) . "\n";
?>
示例 #2 OO example
<?php
$fmt = new MessageFormatter( "en_US", "{0, number} monkeys on {1, number} trees" );
echo "Default pattern: '" . $fmt->getPattern() . "'\n";
echo "Formatting result: " . $fmt->format(array(123, 456)) . "\n";
$fmt->setPattern("{0, number} trees hosting {1, number} monkeys" );
echo "New pattern: '" . $fmt->getPattern() . "'\n";
echo "Formatted number: " . $fmt->format(array(123, 456)) . "\n";
?>
以上例程会输出:
Default pattern: '{0,number} monkeys on {1,number} trees'
Formatting result: 123 monkeys on 456 trees
New pattern: '{0,number} trees hosting {1,number} monkeys'
Formatted number: 123 trees hosting 456 monkeys
参见
- msgfmt_create
- msgfmt_get_pattern
简介
类摘要
IntlCalendar
class IntlCalendar {
/* 常量 */
const int
IntlCalendar::FIELD_ERA
= 0 ;
const int
IntlCalendar::FIELD_YEAR
= 1 ;
const int
IntlCalendar::FIELD_MONTH
= 2 ;
const int
IntlCalendar::FIELD_WEEK_OF_YEAR
= 3
;
const int
IntlCalendar::FIELD_WEEK_OF_MONTH
=
4 ;
const int
IntlCalendar::FIELD_DATE
= 5 ;
const int
IntlCalendar::FIELD_DAY_OF_YEAR
= 6
;
const int
IntlCalendar::FIELD_DAY_OF_WEEK
= 7
;
const int
IntlCalendar::FIELD_DAY_OF_WEEK_IN_MONTH
=
8 ;
const int
IntlCalendar::FIELD_AM_PM
= 9 ;
const int
IntlCalendar::FIELD_HOUR
= 10 ;
const int
IntlCalendar::FIELD_HOUR_OF_DAY
= 11
;
const int
IntlCalendar::FIELD_MINUTE
= 12 ;
const int
IntlCalendar::FIELD_SECOND
= 13 ;
const int
IntlCalendar::FIELD_MILLISECOND
= 14
;
const int
IntlCalendar::FIELD_ZONE_OFFSET
= 15
;
const int
IntlCalendar::FIELD_DST_OFFSET
= 16
;
const int
IntlCalendar::FIELD_YEAR_WOY
= 17 ;
const int
IntlCalendar::FIELD_DOW_LOCAL
= 18 ;
const int
IntlCalendar::FIELD_EXTENDED_YEAR
=
19 ;
const int
IntlCalendar::FIELD_JULIAN_DAY
= 20
;
const int
IntlCalendar::FIELD_MILLISECONDS_IN_DAY
=
21 ;
const int
IntlCalendar::FIELD_IS_LEAP_MONTH
=
22 ;
const int
IntlCalendar::FIELD_FIELD_COUNT
=
23 ;
const int
IntlCalendar::FIELD_DAY_OF_MONTH
= 5
;
const int
IntlCalendar::DOW_SUNDAY
= 1 ;
const int
IntlCalendar::DOW_MONDAY
= 2 ;
const int
IntlCalendar::DOW_TUESDAY
= 3 ;
const int
IntlCalendar::DOW_WEDNESDAY
= 4 ;
const int
IntlCalendar::DOW_THURSDAY
= 5 ;
const int
IntlCalendar::DOW_FRIDAY
= 6 ;
const int
IntlCalendar::DOW_SATURDAY
= 7 ;
const int
IntlCalendar::DOW_TYPE_WEEKDAY
= 0 ;
const int
IntlCalendar::DOW_TYPE_WEEKEND
= 1 ;
const int
IntlCalendar::DOW_TYPE_WEEKEND_OFFSET
=
2 ;
const int
IntlCalendar::DOW_TYPE_WEEKEND_CEASE
=
3 ;
const int
IntlCalendar::WALLTIME_FIRST
= 1 ;
const int
IntlCalendar::WALLTIME_LAST
= 0 ;
const int
IntlCalendar::WALLTIME_NEXT_VALID
=
2 ;
/* 方法 */
public bool
add ( <span
class="type">int $field
, <span
class="methodparam">int $amount
)
bool <span
class="methodname">intlcal_add ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $field
,
int $amount
)
public bool
after ( <span
class="type">IntlCalendar $other
)
bool <span
class="methodname">intlcal_after ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
public bool
before ( <span
class="type">IntlCalendar $other
)
bool <span
class="methodname">intlcal_before ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
public bool
clear ([ <span
class="methodparam">int $field
<span
class="initializer"> = NULL ] )
bool <span
class="methodname">intlcal_clear ( <span
class="methodparam">IntlCalendar $cal
[, int
$field
= NULL ] )
private <span class="methodname">__construct ( <span class="methodparam">void )
public <span
class="modifier">static IntlCalendar
createInstance ([ <span
class="methodparam">mixed $timeZone
<span
class="initializer"> = NULL [, <span
class="methodparam">string $locale
<span
class="initializer"> = "" ]] )
IntlCalendar <span
class="methodname">intlcal_create_instance ([ <span
class="methodparam">mixed $timeZone
<span
class="initializer"> = NULL [, <span
class="methodparam">string $locale
<span
class="initializer"> = "" ]] )
public bool
equals ( <span
class="type">IntlCalendar $other
)
bool <span
class="methodname">intlcal_equals ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
public <span
class="type">intfalse <span
class="methodname">fieldDifference ( <span
class="methodparam">float $when
,
int $field
)
int<span
class="type">false <span
class="methodname">intlcal_field_difference ( <span
class="methodparam">IntlCalendar $cal
, float
$when
, int
$field
)
public <span
class="modifier">static IntlCalendar
fromDateTime ( <span
class="methodparam">mixed $dateTime
)
IntlCalendar <span
class="methodname">intlcal_from_date_time ( <span
class="methodparam">mixed $dateTime
)
public int <span
class="methodname">get ( <span
class="type">int $field
)
int <span
class="methodname">intlcal_get ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $field
)
public <span
class="type">intfalse <span
class="methodname">getActualMaximum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_actual_maximum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span
class="type">intfalse <span
class="methodname">getActualMinimum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_actual_minimum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span class="modifier">static array <span class="methodname">getAvailableLocales ( <span class="methodparam">void )
array <span class="methodname">intlcal_get_available_locales ( <span class="methodparam">void )
public <span
class="type">intfalse <span
class="methodname">getDayOfWeekType ( <span
class="methodparam">int $dayOfWeek
)
int<span
class="type">false <span
class="methodname">intlcal_get_day_of_week_type ( <span
class="methodparam">IntlCalendar $cal
, int
$dayOfWeek
)
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
public <span class="type">intfalse <span class="methodname">getFirstDayOfWeek ( <span class="methodparam">void )
int<span
class="type">false <span
class="methodname">intlcal_get_first_day_of_week ( <span
class="methodparam">IntlCalendar $cal
)
public <span
class="type">intfalse <span
class="methodname">getGreatestMinimum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_greatest_minimum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span
class="modifier">static <span
class="type">Iteratorfalse <span
class="methodname">getKeywordValuesForLocale ( <span
class="methodparam">string $key
,
string
$locale
, <span
class="type">bool $commonlyUsed
)
static <span
class="type">Iteratorfalse <span
class="methodname">intlcal_get_keyword_values_for_locale (
string $key
, string
$locale
, <span
class="type">bool $commonlyUsed
)
public <span
class="type">intfalse <span
class="methodname">getLeastMaximum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_least_maximum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span
class="type">stringfalse <span
class="methodname">getLocale ( <span
class="type">int $localeType
)
string<span
class="type">false <span
class="methodname">intlcal_get_locale ( <span
class="methodparam">IntlCalendar $cal
, int
$localeType
)
public <span
class="type">intfalse <span
class="methodname">getMaximum ( <span
class="type">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_maximum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span class="type">intfalse <span class="methodname">getMinimalDaysInFirstWeek ( <span class="methodparam">void )
int<span
class="type">false <span
class="methodname">intlcal_get_minimal_days_in_first_week (
IntlCalendar
$cal
)
public <span
class="type">intfalse <span
class="methodname">getMinimum ( <span
class="type">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_minimum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span class="modifier">static float <span class="methodname">getNow ( void )
float <span class="methodname">intlcal_get_now ( <span class="methodparam">void )
public int <span class="methodname">getRepeatedWallTimeOption ( <span class="methodparam">void )
int <span
class="methodname">intlcal_get_repeated_wall_time_option (
IntlCalendar
$cal
)
public int <span class="methodname">getSkippedWallTimeOption ( <span class="methodparam">void )
int <span
class="methodname">intlcal_get_skipped_wall_time_option (
IntlCalendar
$cal
)
public float getTime ( <span class="methodparam">void )
float <span
class="methodname">intlcal_get_time ( <span
class="methodparam">IntlCalendar $cal
)
public <span class="type">IntlTimeZone <span class="methodname">getTimeZone ( <span class="methodparam">void )
IntlTimeZone <span
class="methodname">intlcal_get_time_zone ( <span
class="methodparam">IntlCalendar $cal
)
public string getType ( <span class="methodparam">void )
string <span
class="methodname">intlcal_get_type ( <span
class="methodparam">IntlCalendar $cal
)
public <span
class="type">intfalse <span
class="methodname">getWeekendTransition ( <span
class="methodparam">string $dayOfWeek
)
int<span
class="type">false <span
class="methodname">intlcal_get_weekend_transition ( <span
class="methodparam">IntlCalendar $cal
, string
$dayOfWeek
)
public bool inDaylightTime ( <span class="methodparam">void )
bool <span
class="methodname">intlcal_in_daylight_time ( <span
class="methodparam">IntlCalendar $cal
)
public bool
isEquivalentTo ( <span
class="methodparam">IntlCalendar
$other
)
bool <span
class="methodname">intlcal_is_equivalent_to ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
public bool isLenient ( <span class="methodparam">void )
bool <span
class="methodname">intlcal_is_lenient ( <span
class="methodparam">IntlCalendar $cal
)
public bool
isSet ( <span
class="type">int $field
)
bool <span
class="methodname">intlcal_is_set ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public bool
isWeekend ([ <span
class="methodparam">float $date
<span
class="initializer"> = NULL ] )
bool <span
class="methodname">intlcal_is_weekend ( <span
class="methodparam">IntlCalendar $cal
[, float
$date
= NULL ] )
public bool
roll ( <span
class="type">int $field
, <span
class="methodparam">mixed
$amountOrUpOrDown
)
bool <span
class="methodname">intlcal_roll ( <span
class="methodparam">IntlCalendar $cal
, int
$field
, <span
class="type">mixed $amountOrUpOrDown
)
public bool
set ( <span
class="type">int $field
, <span
class="methodparam">int $value
)
public bool
set ( <span
class="type">int $year
, <span
class="type">int $month
[, <span
class="methodparam">int $dayOfMonth
<span
class="initializer"> = NULL [, <span
class="methodparam">int $hour
<span
class="initializer"> = NULL [, <span
class="methodparam">int $minute
<span
class="initializer"> = NULL [, <span
class="methodparam">int $second
<span
class="initializer"> = NULL ]]]] )
bool <span
class="methodname">intlcal_set ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $field
,
int $value
)
bool <span
class="methodname">intlcal_set ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $year
, <span
class="methodparam">int $month
[,
int
$dayOfMonth
= NULL [, <span
class="methodparam">int $hour
<span
class="initializer"> = NULL [, <span
class="methodparam">int $minute
<span
class="initializer"> = NULL [, <span
class="methodparam">int $second
<span
class="initializer"> = NULL ]]]] )
public bool
setFirstDayOfWeek ( <span
class="methodparam">int $dayOfWeek
)
bool <span
class="methodname">intlcal_set_first_day_of_week ( <span
class="methodparam">IntlCalendar $cal
, int
$dayOfWeek
)
public bool
setLenient ( <span
class="methodparam">bool $isLenient
)
bool <span
class="methodname">intlcal_set_lenient ( <span
class="methodparam">IntlCalendar $cal
, bool
$isLenient
)
public bool
setMinimalDaysInFirstWeek ( <span
class="methodparam">int $minimalDays
)
bool <span
class="methodname">intlcal_set_minimal_days_in_first_week (
IntlCalendar
$cal
, int
$minimalDays
)
public bool
setRepeatedWallTimeOption ( <span
class="methodparam">int
$wallTimeOption
)
bool <span
class="methodname">intlcal_set_repeated_wall_time_option (
IntlCalendar
$cal
, int
$wallTimeOption
)
public bool
setSkippedWallTimeOption ( <span
class="methodparam">int
$wallTimeOption
)
bool <span
class="methodname">intlcal_set_skipped_wall_time_option (
IntlCalendar
$cal
, int
$wallTimeOption
)
public bool
setTime ( <span
class="methodparam">float $date
)
bool <span
class="methodname">intlcal_set_time ( <span
class="methodparam">IntlCalendar $cal
, float
$date
)
public bool
setTimeZone ( <span
class="methodparam">mixed $timeZone
)
bool <span
class="methodname">intlcal_set_time_zone ( <span
class="methodparam">IntlCalendar $cal
, mixed
$timeZone
)
public DateTime toDateTime ( <span class="methodparam">void )
DateTime <span
class="methodname">intlcal_to_date_time ( <span
class="methodparam">IntlCalendar $cal
)
}
预定义常量
IntlCalendar::FIELD_ERA
Calendar field numerically representing an era, for instance 1 for AD
and 0 for BC in the Gregorian/Julian calendars and 235 for the
Heisei (平成) era in the Japanese calendar. Not all calendars have more
than one era.
IntlCalendar::FIELD_YEAR
Calendar field for the year. This is not unique across eras. If the
calendar type has more than one era, generally the minimum value for
this field will be 1.
IntlCalendar::FIELD_MONTH
Calendar field for the month. The month sequence is zero-based, so
January (here used to signify the first month of the calendar; this may
be called another name, such as Muharram in the Islamic calendar) is
represented by 0, February by 1, …, December by 11 and, for
calendars that have it, the 13th or leap month by 12.
IntlCalendar::FIELD_WEEK_OF_YEAR
Calendar field for the number of the week of the year. This depends on
which day of the week is
deemed to start the week
and the
minimal number of days in a week.
IntlCalendar::FIELD_WEEK_OF_MONTH
Calendar field for the number of the week of the month. This depends on
which day of the week is
deemed to start the week
and the
minimal number of days in a week.
IntlCalendar::FIELD_DATE
Calendar field for the day of the month. The same as
IntlCalendar::FIELD_DAY_OF_MONTH
, which has a clearer name.
IntlCalendar::FIELD_DAY_OF_YEAR
Calendar field for the day of the year. For the Gregorian calendar,
starts with 1
and ends with 365
or 366
.
IntlCalendar::FIELD_DAY_OF_WEEK
Calendar field for the day of the week. Its values start with 1
(Sunday, see
IntlCalendar::DOW_SUNDAY
and subsequent constants) and the last valid value is 7 (Saturday).
IntlCalendar::FIELD_DAY_OF_WEEK_IN_MONTH
Given a day of the week (Sunday, Monday, …), this calendar field assigns
an ordinal to such a day of the week in a specific month. Thus, if the
value of this field is 1 and the value of the day of the week is 2
(Monday), then the set day of the month is the 1st Monday of the month;
the maximum value is 5.
Additionally, the value 0 and negative values are also allowed. The value 0 encompasses the seven days that occur immediately before the first seven days of a month (which therefore have a ‘day of week in month’ with value 1). Negative values starts counting from the end of the month – -1 points to the last occurrence of a day of the week in a month, -2 to the second last, and so on.
Unlike
IntlCalendar::FIELD_WEEK_OF_MONTH
and
IntlCalendar::FIELD_WEEK_OF_YEAR
,
this value does not depend on <span
class="function">IntlCalendar::getFirstDayOfWeek or on <span
class="function">IntlCalendar::getMinimalDaysInFirstWeek. The
first Monday is the first Monday, even if it occurs in a week that
belongs to the previous month.
IntlCalendar::FIELD_AM_PM
Calendar field indicating whether a time is before noon (value 0, AM)
or after (1). Midnight is AM, noon is PM.
IntlCalendar::FIELD_HOUR
Calendar field for the hour, without specifying whether itʼs in the
morning or in the afternoon. Valid values are 0 to 11.
IntlCalendar::FIELD_HOUR_OF_DAY
Calendar field for the full (24h) hour of the day. Valid values are 0
to 23.
IntlCalendar::FIELD_MINUTE
Calendar field for the minutes component of the time.
IntlCalendar::FIELD_SECOND
Calendar field for the seconds component of the time.
IntlCalendar::FIELD_MILLISECOND
Calendar field the milliseconds component of the time.
IntlCalendar::FIELD_ZONE_OFFSET
Calendar field indicating the raw offset of the timezone, in
milliseconds. The raw offset is the timezone offset, excluding any
offset due to daylight saving time.
IntlCalendar::FIELD_DST_OFFSET
Calendar field for the daylight saving time offset of the calendarʼs
timezone, in milliseconds, if active for calendarʼs time.
IntlCalendar::FIELD_YEAR_WOY
Calendar field representing the year for
week of year
purposes.
IntlCalendar::FIELD_DOW_LOCAL
Calendar field for the localized day of the week. This is a value
between 1 and 7, 1 being used for the day of the week that matches
the value returned by <span
class="function">IntlCalendar::getFirstDayOfWeek.
IntlCalendar::FIELD_EXTENDED_YEAR
Calendar field for a year number representation that is continuous
across eras. For the Gregorian calendar, the value of this field matches
that of IntlCalendar::FIELD_YEAR
for AD years; a BC year y is
represented by -y + 1.
IntlCalendar::FIELD_JULIAN_DAY
Calendar field for a modified Julian day number. It is different from a
conventional Julian day number in that its transitions occur at local
zone midnight rather than at noon UTC. It uniquely identifies a date.
IntlCalendar::FIELD_MILLISECONDS_IN_DAY
Calendar field encompassing the information in
IntlCalendar::FIELD_HOUR_OF_DAY
, IntlCalendar::FIELD_MINUTE
,
IntlCalendar::FIELD_SECOND
and
IntlCalendar::FIELD_MILLISECOND
. Range is from the 0 to 24 *
3600 * 1000 - 1. It is not the amount of milliseconds elapsed in the
day since on DST transitions it will have discontinuities analog to
those of the wall time.
IntlCalendar::FIELD_IS_LEAP_MONTH
Calendar field whose value is 1 for indicating a leap month and 0
otherwise.
IntlCalendar::FIELD_FIELD_COUNT
The total number of fields.
IntlCalendar::FIELD_DAY_OF_MONTH
Alias for
IntlCalendar::FIELD_DATE
.
IntlCalendar::DOW_SUNDAY
Sunday.
IntlCalendar::DOW_MONDAY
Monday.
IntlCalendar::DOW_TUESDAY
Tuesday.
IntlCalendar::DOW_WEDNESDAY
Wednesday.
IntlCalendar::DOW_THURSDAY
Thursday.
IntlCalendar::DOW_FRIDAY
Friday.
IntlCalendar::DOW_SATURDAY
Saturday.
IntlCalendar::DOW_TYPE_WEEKDAY
Output of IntlCalendar::getDayOfWeekType
indicating a day of week is a weekday.
IntlCalendar::DOW_TYPE_WEEKEND
Output of IntlCalendar::getDayOfWeekType
indicating a day of week belongs to the weekend.
IntlCalendar::DOW_TYPE_WEEKEND_OFFSET
Output of IntlCalendar::getDayOfWeekType
indicating the weekend begins during the given day of week.
IntlCalendar::DOW_TYPE_WEEKEND_CEASE
Output of IntlCalendar::getDayOfWeekType
indicating the weekend ends during the given day of week.
IntlCalendar::WALLTIME_FIRST
Output of <span
class="function">IntlCalendar::getSkippedWallTimeOption
indicating that wall times in the skipped range should refer to the same
instant as wall times with one hour less and of <span
class="function">IntlCalendar::getRepeatedWallTimeOption
indicating the wall times in the repeated range should refer to the
instant of the first occurrence of such wall time.
IntlCalendar::WALLTIME_LAST
Output of <span
class="function">IntlCalendar::getSkippedWallTimeOption
indicating that wall times in the skipped range should refer to the same
instant as wall times with one hour after and of <span
class="function">IntlCalendar::getRepeatedWallTimeOption
indicating the wall times in the repeated range should refer to the
instant of the second occurrence of such wall time.
IntlCalendar::WALLTIME_NEXT_VALID
Output of <span
class="function">IntlCalendar::getSkippedWallTimeOption
indicating that wall times in the skipped range should refer to the
instant when the daylight saving time transition occurs (begins).
IntlCalendar::add
Add a (signed) amount of time to a field
说明
面向对象风格
public bool
IntlCalendar::add ( <span
class="methodparam">int $field
,
int $amount
)
过程化风格
bool <span
class="methodname">intlcal_add ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $field
,
int $amount
)
Add a signed amount to a field. Adding a positive amount allows advances in time, even if the numeric value of the field decreases (e.g. when working with years in BC dates).
Other fields may need to adjusted – for instance, adding a month to the 31st of January will result in the 28th (or 29th) of February. Contrary to IntlCalendar::roll, when a value wraps around, more significant fields may change. For instance, adding a day to the 31st of January will result in the 1st of February, not the 1st of January.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
amount
The signed amount to add to the current field. If the amount is
positive, the instant will be moved forward; if it is negative, the
instant will be moved into the past. The unit is implicit to the field
type. For instance, hours for IntlCalendar::FIELD_HOUR_OF_DAY
.
返回值
Returns true
on success 或者在失败时返回 false
.
范例
示例 #1 IntlCalendar::add
<?php
ini_set('intl.default_locale', 'fr_FR');
ini_set('date.timezone', 'UTC');
$cal = new IntlGregorianCalendar(2012, 0 /* January */, 31);
echo IntlDateFormatter::formatObject($cal), "\n";
$cal->add(IntlCalendar::FIELD_MONTH, 1);
echo IntlDateFormatter::formatObject($cal), "\n";
$cal->add(IntlCalendar::FIELD_DAY_OF_MONTH, 1);
echo IntlDateFormatter::formatObject($cal), "\n";
以上例程会输出:
31 janv. 2012 00:00:00
29 févr. 2012 00:00:00
1 mars 2012 00:00:00
IntlCalendar::after
Whether this objectʼs time is after that of the passed object
说明
面向对象风格
public bool
IntlCalendar::after ( <span
class="methodparam">IntlCalendar
$other
)
过程化风格
bool <span
class="methodname">intlcal_after ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
Returns whether this objectʼs time succeeds the argumentʼs time.
参数
cal
The IntlCalendar resource.
other
The calendar whose time will be checked against the primary objectʼs
time.
返回值
Returns true
if this objectʼs current time is after that of the
calendar
argumentʼs time. Returns false
otherwise. Also returns
false
on failure. You can use
exceptions or <span
class="function">intl_get_error_code to detect error
conditions.
范例
示例 #1 IntlCalendar::after
<?php
$cal1 = IntlCalendar::createInstance();
$cal2 = clone $cal1;
var_dump($cal1->after($cal2), //false
$cal2->after($cal1)); //false
$cal1->roll(IntlCalendar::FIELD_MILLISECOND, true);
var_dump($cal1->after($cal2), //true
$cal2->after($cal1)); //false
IntlCalendar::before
Whether this objectʼs time is before that of the passed object
说明
面向对象风格
public bool
IntlCalendar::before ( <span
class="methodparam">IntlCalendar
$other
)
过程化风格
bool <span
class="methodname">intlcal_before ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
Returns whether this objectʼs time precedes the argumentʼs time.
参数
cal
The IntlCalendar resource.
other
The calendar whose time will be checked against the primary objectʼs
time.
返回值
Returns true
if this objectʼs current time is before that of the
calendar
argumentʼs time. Returns false
otherwise. Also returns
false
on failure. You can use
exceptions or <span
class="function">intl_get_error_code to detect error
conditions.
IntlCalendar::clear
Clear a field or all fields
说明
面向对象风格
public bool
IntlCalendar::clear ([ <span
class="methodparam">int $field
<span
class="initializer"> = NULL ] )
过程化风格
bool <span
class="methodname">intlcal_clear ( <span
class="methodparam">IntlCalendar $cal
[, int
$field
= NULL ] )
Clears either all of the fields or a specific field. A cleared field is marked as unset, giving it the lowest priority against overlapping fields or even default values when calculating the time. Additionally, its value is set to 0, though given the fieldʼs low priority, its value may have been internally set to another value by the time the field has finished been queried.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
Returns true
on success 或者在失败时返回 false
. Failure can
only occur is invalid arguments are provided.
范例
示例 #1 IntlCalendar::clear examples
<?php
ini_set('intl.default_locale', 'es_ES');
ini_set('date.timezone', 'UTC');
$fields = array(
'FIELD_ERA' => 0,
'FIELD_YEAR' => 1,
'FIELD_MONTH' => 2,
'FIELD_WEEK_OF_YEAR' => 3,
'FIELD_WEEK_OF_MONTH' => 4,
'FIELD_DATE' => 5,
'FIELD_DAY_OF_YEAR' => 6,
'FIELD_DAY_OF_WEEK' => 7,
'FIELD_DAY_OF_WEEK_IN_MONTH' => 8,
'FIELD_AM_PM' => 9,
'FIELD_HOUR' => 10,
'FIELD_HOUR_OF_DAY' => 11,
'FIELD_MINUTE' => 12,
'FIELD_SECOND' => 13,
'FIELD_MILLISECOND' => 14,
'FIELD_ZONE_OFFSET' => 15,
'FIELD_DST_OFFSET' => 16,
'FIELD_YEAR_WOY' => 17,
'FIELD_DOW_LOCAL' => 18,
'FIELD_EXTENDED_YEAR' => 19,
'FIELD_JULIAN_DAY' => 20,
'FIELD_MILLISECONDS_IN_DAY' => 21,
'FIELD_IS_LEAP_MONTH' => 22,
'FIELD_FIELD_COUNT' => 23,
);
function getSetFields(IntlCalendar $cal) {
global $fields;
$ret = array();
foreach ($fields as $name => $value) {
if ($cal->isSet($value)) {
$ret[] = $name;
}
}
return $ret;
}
$cal = new IntlGregorianCalendar(2013, 2 /* March */, 15);
echo "After GregorianCalendar creation\n";
print_r(getSetFields($cal));
echo "\n";
echo IntlDateFormatter::formatObject($cal), "\n";
echo "After the formatter requested the extended year\n";
print_r(getSetFields($cal));
echo "\n";
$cal->clear(IntlCalendar::FIELD_YEAR);
echo "After the year has been cleared, the date stays the same\n";
echo IntlDateFormatter::formatObject($cal), "\n";
echo "because FIELD_EXTENDED_YEAR is still set\n";
print_r(getSetFields($cal));
echo "\n";
var_dump($cal->clear(IntlCalendar::FIELD_EXTENDED_YEAR));
echo "After the extended year has been cleared\n";
print_r(getSetFields($cal));
echo IntlDateFormatter::formatObject($cal), "\n";
echo "\n";
echo "After the fields are recalculated,\n"
. " extended year is set again (to 1970)\n";
print_r(getSetFields($cal));
echo "\n";
$cal->clear();
echo "After calling variant with no arguments\n";
print_r(getSetFields($cal));
echo IntlDateFormatter::formatObject($cal), "\n";
以上例程会输出:
After GregorianCalendar creation
Array
(
[0] => FIELD_ERA
[1] => FIELD_YEAR
[2] => FIELD_MONTH
[3] => FIELD_DATE
)
15/03/2013 00:00:00
After the formatter requested the extended year
Array
(
[0] => FIELD_ERA
[1] => FIELD_YEAR
[2] => FIELD_MONTH
[3] => FIELD_DATE
[4] => FIELD_EXTENDED_YEAR
)
After the year has been cleared, the date stays the same
15/03/2013 00:00:00
because FIELD_EXTENDED_YEAR is still set
Array
(
[0] => FIELD_ERA
[1] => FIELD_MONTH
[2] => FIELD_DATE
[3] => FIELD_EXTENDED_YEAR
)
bool(true)
After the extended year has been cleared
Array
(
[0] => FIELD_ERA
[1] => FIELD_MONTH
[2] => FIELD_DATE
)
15/03/1970 00:00:00
After the fields are recalculated,
extended year is set again (to 1970)
Array
(
[0] => FIELD_ERA
[1] => FIELD_MONTH
[2] => FIELD_DATE
[3] => FIELD_EXTENDED_YEAR
)
After calling variant with no arguments
Array
(
)
01/01/1970 00:00:00
IntlCalendar::__construct
Private constructor for disallowing instantiation
说明
private <span class="methodname">IntlCalendar::__construct ( <span class="methodparam">void )
A private constructor for disallowing instantiation with the new operator.
Call IntlCalendar::createInstance instead.
参数
此函数没有参数。
返回值
没有返回值。
IntlCalendar::createInstance
Create a new IntlCalendar
说明
面向对象风格
public <span
class="modifier">static IntlCalendar
IntlCalendar::createInstance ([ <span
class="methodparam">mixed $timeZone
<span
class="initializer"> = NULL [, <span
class="methodparam">string $locale
<span
class="initializer"> = "" ]] )
过程化风格
IntlCalendar <span
class="methodname">intlcal_create_instance ([ <span
class="methodparam">mixed $timeZone
<span
class="initializer"> = NULL [, <span
class="methodparam">string $locale
<span
class="initializer"> = "" ]] )
Given a timezone and locale, this method creates an <span class="classname">IntlCalendar object. This factory method may return a subclass of IntlCalendar.
The calendar created will represent the time instance at which it was created, based on the system time. The fields can all be cleared by calling IntCalendar::clear with no arguments. See also <span class="function">IntlGregorianCalendar::__construct.
参数
timeZone
The timezone to use.
-
null
, in which case the default timezone will be used, as specified in the ini setting date.timezone or through the function <span class="function">date_default_timezone_set and as returned by date_default_timezone_get. -
An IntlTimeZone, which will be used directly.
-
A DateTimeZone. Its identifier will be extracted and an ICU timezone object will be created; the timezone will be backed by ICUʼs database, not PHPʼs.
-
A string, which should be a valid ICU timezone identifier. See <span class="function">IntlTimeZone::createTimeZoneIDEnumeration. Raw offsets such as "GMT+08:30" are also accepted.
locale
A locale to use or null
to use
the default locale.
返回值
The created IntlCalendar instance or
null
on failure.
范例
示例 #1 IntlCalendar::createInstance
<?php
ini_set('intl.default_locale', 'es_ES');
ini_set('date.timezone', 'Europe/Madrid');
$cal = IntlCalendar::createInstance();
echo "No arguments\n";
var_dump(get_class($cal),
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL));
echo "\n";
echo "Explicit timezone\n";
$cal = IntlCalendar::createInstance(IntlTimeZone::getGMT());
var_dump(get_class($cal),
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL));
echo "\n";
echo "Explicit locale (with calendar)\n";
$cal = IntlCalendar::createInstance(NULL, 'es_ES@calendar=persian');
var_dump(get_class($cal),
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL));
以上例程会输出:
No arguments
string(21) "IntlGregorianCalendar"
string(68) "martes 18 de junio de 2013 14:11:02 Hora de verano de Europa Central"
Explicit timezone
string(21) "IntlGregorianCalendar"
string(45) "martes 18 de junio de 2013 12:11:02 GMT+00:00"
Explicit locale (with calendar)
string(12) "IntlCalendar"
string(70) "martes 28 de Khordad de 1392 14:11:02 Hora de verano de Europa Central"
参见
- IntlGregorianCalendar::__construct
IntlCalendar::equals
Compare time of two IntlCalendar objects for equality
说明
面向对象风格
public bool
IntlCalendar::equals ( <span
class="methodparam">IntlCalendar
$other
)
过程化风格
bool <span
class="methodname">intlcal_equals ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
Returns true if this calendar and the given calendar have the same time. The settings, calendar types and field states do not have to be the same.
参数
cal
The IntlCalendar resource.
other
The calendar to compare with the primary object.
返回值
Returns true
if the current time of both this and the passed in
IntlCalendar object are the same, or
false
otherwise. The value false
can also be returned on
failure. This can only happen if bad arguments are passed in. In any
case, the two cases can be distinguished by calling <span
class="function">intl_get_error_code.
范例
示例 #1 IntlCalendar::equals
<?php
ini_set('date.timezone', 'UTC');
$cal1 = IntlCalendar::createInstance(NULL, 'es_ES');
$cal2 = clone $cal1;
var_dump($cal1->equals($cal2)); //TRUE
//The locale is not included in the comparison
$cal2 = IntlCalendar::createInstance(NULL, 'pt_PT');
$cal2->setTime($cal1->getTime());
var_dump($cal1->equals($cal2)); //TRUE
//And set fields state is not included as well
$cal2->clear(IntlCalendar::FIELD_YEAR);
var_dump($cal1->isSet(IntlCalendar::FIELD_YEAR) ==
$cal2->isSet(IntlCalendar::FIELD_YEAR)); //FALSE
var_dump($cal1->equals($cal2)); //TRUE
//Neither is the calendar type
$cal2 = IntlCalendar::createInstance(NULL, 'es_ES@calendar=islamic');
$cal2->setTime($cal1->getTime());
var_dump($cal1->equals($cal2)); //TRUE
//Only the time is
$cal2 = clone $cal1;
$cal2->setTime($cal1->getTime() + 1.);
var_dump($cal1->equals($cal2)); //FALSE
IntlCalendar::fieldDifference
Calculate difference between given time and this objectʼs time
说明
面向对象风格
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::fieldDifference ( <span
class="methodparam">float $when
,
int $field
)
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_field_difference ( <span
class="methodparam">IntlCalendar $cal
, float
$when
, int
$field
)
Return the difference between the given time and the time this object is
set to, with respect to the quantity specified the field
parameter.
This method is meant to be called successively, first with the most significant field of interest down to the least significant field. To this end, as a side effect, this calendarʼs value for the field specified is advanced by the amount returned.
参数
cal
The IntlCalendar resource.
when
The time against which to compare the quantity represented by the
field
. For the result to be positive, the time given for this
parameter must be ahead of the time of the object the method is being
invoked on.
field
The field that represents the quantity being compared.
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
Returns a (signed) difference of time in the unit associated with the
specified field 或者在失败时返回 false
.
范例
示例 #1 IntlCalendar::fieldDifference
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'fr_FR');
$cal1 = IntlCalendar::fromDateTime('2012-02-29 09:00:11');
$cal2 = IntlCalendar::fromDateTime('2013-03-01 09:19:29');
$time = $cal2->getTime();
echo "Time before: ", IntlDateFormatter::formatObject($cal1), "\n";
printf(
"The difference in time is %d year(s), %d month(s), "
. "%d day(s), %d hour(s) and %d minute(s)\n",
$cal1->fieldDifference($time, IntlCalendar::FIELD_YEAR),
$cal1->fieldDifference($time, IntlCalendar::FIELD_MONTH),
$cal1->fieldDifference($time, IntlCalendar::FIELD_DAY_OF_MONTH),
$cal1->fieldDifference($time, IntlCalendar::FIELD_HOUR_OF_DAY),
$cal1->fieldDifference($time, IntlCalendar::FIELD_MINUTE)
);
//now it was advanced to the target time, exception for the seconds,
//for which we did not measure the difference
echo "Time after: ", IntlDateFormatter::formatObject($cal1), "\n";
以上例程会输出:
Time before: 29 févr. 2012 09:00:11
The difference in time is 1 year(s), 0 month(s), 1 day(s), 0 hour(s) and 19 minute(s)
Time after: 1 mars 2013 09:19:11
IntlCalendar::fromDateTime
Create an IntlCalendar from a DateTime object or string
说明
面向对象风格
public <span
class="modifier">static IntlCalendar
IntlCalendar::fromDateTime ( <span
class="methodparam">mixed $dateTime
)
过程化风格
IntlCalendar <span
class="methodname">intlcal_from_date_time ( <span
class="methodparam">mixed $dateTime
)
Creates an IntlCalendar object either from a DateTime object or from a string from which a DateTime object can be built.
The new calendar will represent not only the same instant as the given DateTime (subject to precision loss for dates very far into the past or future), but also the same timezone (subject to the caveat that different timezone databases will be used, and therefore the results may differ).
参数
dateTime
A DateTime object or a <span
class="type">string that can be passed to <span
class="function">DateTime::__construct.
返回值
The created IntlCalendar object or
null
in case of failure. If a string is
passed, any exception that occurs inside the <span
class="classname">DateTime constructor is propagated.
范例
示例 #1 IntlCalendar::fromDateTime
<?php
ini_set('date.timezone', 'Europe/Lisbon');
//same as IntlCalendar::fromDateTime(new DateTime(...))
$cal1 = IntlCalendar::fromDateTime('2013-02-28 00:01:02 Europe/Berlin');
//Note the timezone is Europe/Berlin, not the default Europe/Lisbon
echo IntlDateFormatter::formatObject($cal1, 'yyyy MMMM d HH:mm:ss VVVV', 'de_DE'), "\n";
以上例程会输出:
2013 Februar 28 00:01:02 Deutschland Zeit
IntlCalendar::get
Get the value for a field
说明
面向对象风格
public int <span
class="methodname">IntlCalendar::get ( <span
class="methodparam">int $field
)
过程化风格
int <span
class="methodname">intlcal_get ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $field
)
Gets the value for a specific field.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
An integer with the value of the time field.
范例
示例 #1 IntlCalendar::get
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'en_US');
$class = new ReflectionClass('IntlCalendar');
$fields = array();
foreach ($class->getConstants() as $name => $val) {
if (strpos($name, 'FIELD_') !== 0 || $val > 22)
continue;
$fields[$val] = $name;
}
$cal = IntlCalendar::createInstance(); // current time
var_dump(IntlDateFormatter::formatObject($cal));
foreach ($fields as $val => $name) {
echo "$val ($name)", "\n ", $cal->get($val), "\n";
}
以上例程会输出:
string(23) "Jul 1, 2013, 4:44:44 AM"
0 (FIELD_ERA)
1
1 (FIELD_YEAR)
2013
2 (FIELD_MONTH)
6
3 (FIELD_WEEK_OF_YEAR)
27
4 (FIELD_WEEK_OF_MONTH)
1
5 (FIELD_DAY_OF_MONTH)
1
6 (FIELD_DAY_OF_YEAR)
182
7 (FIELD_DAY_OF_WEEK)
2
8 (FIELD_DAY_OF_WEEK_IN_MONTH)
1
9 (FIELD_AM_PM)
0
10 (FIELD_HOUR)
4
11 (FIELD_HOUR_OF_DAY)
4
12 (FIELD_MINUTE)
44
13 (FIELD_SECOND)
44
14 (FIELD_MILLISECOND)
551
15 (FIELD_ZONE_OFFSET)
0
16 (FIELD_DST_OFFSET)
3600000
17 (FIELD_YEAR_WOY)
2013
18 (FIELD_DOW_LOCAL)
2
19 (FIELD_EXTENDED_YEAR)
2013
20 (FIELD_JULIAN_DAY)
2456475
21 (FIELD_MILLISECONDS_IN_DAY)
17084551
22 (FIELD_IS_LEAP_MONTH)
0
IntlCalendar::getActualMaximum
The maximum value for a field, considering the objectʼs current time
说明
面向对象风格
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getActualMaximum ( <span
class="methodparam">int $field
)
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_actual_maximum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
Returns a fieldʼs relative maximum value around the current time. The exact semantics vary by field, but in the general case this is the value that would be obtained if one would set the field value into the smallest relative maximum for the field and would increment it until reaching the global maximum or the field value wraps around, in which the value returned would be the global maximum or the value before the wrapping, respectively.
For instance, in the gregorian calendar, the actual maximum value for the day of month would vary between 28 and 31, depending on the month and year of the current time.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
An int representing the maximum value in the
units associated with the given field
或者在失败时返回 false
.
范例
示例 #1 <span class="function">IntlCalendar::getActualMaximum
<?php
ini_set('date.timezone', 'Europe/Lisbon');
$cal = IntlCalendar::fromDateTime('2013-02-15');
var_dump($cal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH)); //28
$cal->add(IntlCalendar::FIELD_EXTENDED_YEAR, -1);
var_dump($cal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH)); //29
以上例程会输出:
int(28)
int(29)
参见
- IntlCalendar::getMaximum
- IntlCalendar::getLeastMaximum
- IntlCalendar::getActualMinimum
IntlCalendar::getActualMinimum
The minimum value for a field, considering the objectʼs current time
说明
面向对象风格
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getActualMinimum ( <span
class="methodparam">int $field
)
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_actual_minimum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
Returns a fieldʼs relative minimum value around the current time. The exact semantics vary by field, but in the general case this is the value that would be obtained if one would set the field value into the greatest relative minimum for the field and would decrement it until reaching the global minimum or the field value wraps around, in which the value returned would be the global minimum or the value before the wrapping, respectively.
For the Gregorian calendar, this is always the same as <span class="function">IntlCalendar::getMinimum.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
An int representing the minimum value in the
fieldʼs unit 或者在失败时返回 false
.
参见
- IntlCalendar::getMinimum
- IntlCalendar::getGreatestMinimum
- IntlCalendar::getActualMaximum
IntlCalendar::getAvailableLocales
Get array of locales for which there is data
说明
面向对象风格
public <span class="modifier">static array <span class="methodname">IntlCalendar::getAvailableLocales ( <span class="methodparam">void )
过程化风格
array <span class="methodname">intlcal_get_available_locales ( <span class="methodparam">void )
Gives the list of locales for which calendars are installed. As of ICU 51, this is the list of all installed ICU locales.
参数
此函数没有参数。
返回值
An array of strings, one for which locale.
范例
示例 #1 <span class="function">IntlCalendar::getAvailableLocales
<?php
print_r(IntlCalendar::getAvailableLocales());
以上例程会输出:
Array
(
[0] => af
[1] => af_NA
[2] => af_ZA
[3] => agq
[4] => agq_CM
[5] => ak
[6] => ak_GH
[7] => am
[8] => am_ET
[9] => ar
[10] => ar_001
[11] => ar_AE
[12] => ar_BH
[13] => ar_DJ
… output abbreviated …
[595] => zh_Hant_HK
[596] => zh_Hant_MO
[597] => zh_Hant_TW
[598] => zu
[599] => zu_ZA
)
IntlCalendar::getDayOfWeekType
Tell whether a day is a weekday, weekend or a day that has a transition between the two
说明
面向对象风格
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getDayOfWeekType ( <span
class="methodparam">int $dayOfWeek
)
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_day_of_week_type ( <span
class="methodparam">IntlCalendar $cal
, int
$dayOfWeek
)
Returns whether the passed day is a weekday
(IntlCalendar::DOW_TYPE_WEEKDAY
), a weekend day
(IntlCalendar::DOW_TYPE_WEEKEND
), a day during which a transition
occurs into the weekend (IntlCalendar::DOW_TYPE_WEEKEND_OFFSET
) or
a day during which the weekend ceases
(IntlCalendar::DOW_TYPE_WEEKEND_CEASE
).
If the return is either IntlCalendar::DOW_TYPE_WEEKEND_OFFSET
or
IntlCalendar::DOW_TYPE_WEEKEND_CEASE
, then <span
class="function">IntlCalendar::getWeekendTransition can be called
to obtain the time of the transition.
This function requires ICU 4.4 or later.
参数
cal
The IntlCalendar resource.
dayOfWeek
One of the constants IntlCalendar::DOW_SUNDAY
,
IntlCalendar::DOW_MONDAY
, …, IntlCalendar::DOW_SATURDAY
.
返回值
Returns one of the constants IntlCalendar::DOW_TYPE_WEEKDAY
,
IntlCalendar::DOW_TYPE_WEEKEND
,
IntlCalendar::DOW_TYPE_WEEKEND_OFFSET
or
IntlCalendar::DOW_TYPE_WEEKEND_CEASE
或者在失败时返回 false
.
范例
示例 #1 <span class="function">IntlCalendar::getDayOfWeekType
<?php
foreach (array('en_US', 'ar_SA') as $locale) {
echo "Locale: ", Locale::getDisplayName($locale, "en_US"), "\n";
$cal = IntlCalendar::createInstance('UTC', $locale);
for ($i = IntlCalendar::DOW_SUNDAY; $i <= IntlCalendar::DOW_SATURDAY; $i++) {
echo $i, " ", $cal->getDayOfWeekType($i), " ",
$cal->getDayOfWeekType($i) >= IntlCalendar::DOW_TYPE_WEEKEND_OFFSET
? $cal->getWeekendTransition($i)
: '',
"\n";
}
echo "\n";
}
以上例程会输出:
Locale: English (United States)
1 3 86400000
2 0
3 0
4 0
5 0
6 0
7 1
Locale: Arabic (Saudi Arabia)
1 0
2 0
3 0
4 0
5 1
6 3 86400000
7 0
IntlCalendar::getErrorCode
intlcal_get_error_code
Get last error code on the object
说明
面向对象风格 (method):
public int <span class="methodname">IntlCalendar::getErrorCode ( <span class="methodparam">void )
过程化风格:
int <span
class="methodname">intlcal_get_error_code ( <span
class="methodparam">IntlCalendar
$calendar
)
Returns the numeric ICU error code for the last call on this object
(including cloning) or the IntlCalendar
given for the calendar
parameter (in the procedural‒style version).
This may indicate only a warning (negative error code) or no error at
all (U_ZERO_ERROR
). The actual presence of an error can be tested
with intl_is_failure.
Invalid arguments detected on the PHP side (before invoking functions of the ICU library) are not recorded for the purposes of this function.
The last error that occurred in any call to a function of the intl extension, including early argument errors, can be obtained with <span class="function">intl_get_error_code. This function resets the global error code, but not the objectʼs error code.
参数
calendar
The calendar object, on the procedural style interface.
返回值
An ICU error code indicating either success, failure or a warning.
范例
示例 #1 IntlCalendar::getErrorCode and IntlCalendar::getErrorMessage
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "nl");
$intlcal = new IntlGregorianCalendar(2012, 1, 29);
var_dump(
$intlcal->getErrorCode(),
$intlcal->getErrorMessage()
);
$intlcal->fieldDifference(-1e100, IntlCalendar::FIELD_SECOND);
var_dump(
$intlcal->getErrorCode(),
$intlcal->getErrorMessage()
);
以上例程会输出:
int(0)
string(12) "U_ZERO_ERROR"
Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in /home/glopes/php/ws/example.php on line 10
int(1)
string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
参见
- IntlCalendar::getErrorMessage
- intl_is_failure
- intl_error_name
- intl_get_error_code
- intl_get_error_message
IntlCalendar::getErrorMessage
intlcal_get_error_message
Get last error message on the object
说明
面向对象风格 (method):
public string IntlCalendar::getErrorMessage ( <span class="methodparam">void )
过程化风格:
string <span
class="methodname">intlcal_get_error_message ( <span
class="methodparam">IntlCalendar
$calendar
)
Returns the error message (if any) associated with the error reported by IntlCalendar::getErrorCode or <span class="function">intlcal_get_error_code. If there is no associated error message, only the string representation of the name of the error constant will be returned. Otherwise, the message also includes a message set on the side of the PHP binding.
参数
calendar
The calendar object, on the procedural style interface.
返回值
The error message associated with last error that occurred in a function call on this object, or a string indicating the non-existance of an error.
范例
示例 #1 IntlCalendar::getErrorMessage
<?php
$cal = IntlCalendar::createInstance('UTC', 'en_US');
var_dump($cal->getErrorMessage());
$cal->getWeekendTransition(IntlCalendar::DOW_WEDNESDAY);
var_dump($cal->getErrorMessage());
以上例程会输出:
string(12) "U_ZERO_ERROR"
string(82) "intlcal_get_weekend_transition: Error calling ICU method: U_ILLEGAL_ARGUMENT_ERROR"
IntlCalendar::getFirstDayOfWeek
Get the first day of the week for the calendarʼs locale
说明
面向对象风格
public <span class="type">intfalse <span class="methodname">IntlCalendar::getFirstDayOfWeek ( <span class="methodparam">void )
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_first_day_of_week ( <span
class="methodparam">IntlCalendar $cal
)
The week day deemed to start a week, either the default value for this locale or the value set with <span class="function">IntlCalendar::setFirstDayOfWeek.
参数
cal
The IntlCalendar resource.
返回值
One of the constants IntlCalendar::DOW_SUNDAY
,
IntlCalendar::DOW_MONDAY
, …, IntlCalendar::DOW_SATURDAY
或者在失败时返回 false
.
范例
示例 #1 <span class="function">IntlCalendar::getFirstDayOfWeek
<?php
ini_set('date.timezone', 'UTC');
$cal1 = IntlCalendar::createInstance(NULL, 'es_ES');
var_dump($cal1->getFirstDayOfWeek()); // Monday
$cal1->set(2013, 1 /* February */, 3); // a Sunday
var_dump($cal1->get(IntlCalendar::FIELD_WEEK_OF_YEAR)); // 5
$cal2 = IntlCalendar::createInstance(NULL, 'en_US');
var_dump($cal2->getFirstDayOfWeek()); // Sunday
$cal2->set(2013, 1 /* February */, 3); // a Sunday
var_dump($cal2->get(IntlCalendar::FIELD_WEEK_OF_YEAR)); // 6
以上例程会输出:
int(2)
int(5)
int(1)
int(6)
参见
- IntlCalendar::setFirstDayOfWeek
IntlCalendar::getGreatestMinimum
Get the largest local minimum value for a field
说明
面向对象风格
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getGreatestMinimum ( <span
class="methodparam">int $field
)
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_greatest_minimum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
Returns the largest local minimum for a field. This should be a value larger or equal to that returned by <span class="function">IntlCalendar::getActualMinimum, which is in its turn larger or equal to that returned by <span class="function">IntlCalendar::getMinimum. All these three functions return the same value for the Gregorian calendar.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
An int representing a field value, in the
fieldʼs unit, 或者在失败时返回 false
.
IntlCalendar::getKeywordValuesForLocale
Get set of locale keyword values
说明
面向对象风格
public <span
class="modifier">static <span
class="type">Iteratorfalse <span
class="methodname">IntlCalendar::getKeywordValuesForLocale (
string $key
, string
$locale
, <span
class="type">bool $commonlyUsed
)
过程化风格
static <span
class="type">Iteratorfalse <span
class="methodname">intlcal_get_keyword_values_for_locale (
string $key
, string
$locale
, <span
class="type">bool $commonlyUsed
)
For a given locale key, get the set of values for that key that would result in a different behavior. For now, only the 'calendar' keyword is supported.
This function requires ICU 4.2 or later.
参数
key
The locale keyword for which relevant values are to be queried. Only
'calendar' is supported.
locale
The locale onto which the keyword/value pair are to be appended.
commonlyUsed
Whether to show only the values commonly used for the specified locale.
返回值
An iterator that yields strings with the locale keyword values
或者在失败时返回 false
.
范例
示例 #1 <span class="function">IntlCalendar::getKeyworkValuesForLocale
<?php
print_r(
iterator_to_array(
IntlCalendar::getKeywordValuesForLocale(
'calendar', 'fa_IR', true)));
print_r(
iterator_to_array(
IntlCalendar::getKeywordValuesForLocale(
'calendar', 'fa_IR', false)));
以上例程会输出:
Array
(
[0] => persian
[1] => gregorian
[2] => islamic
[3] => islamic-civil
)
Array
(
[0] => persian
[1] => gregorian
[2] => islamic
[3] => islamic-civil
[4] => japanese
[5] => buddhist
[6] => roc
[7] => hebrew
[8] => chinese
[9] => indian
[10] => coptic
[11] => ethiopic
[12] => ethiopic-amete-alem
)
IntlCalendar::getLeastMaximum
Get the smallest local maximum for a field
说明
面向对象风格
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getLeastMaximum ( <span
class="methodparam">int $field
)
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_least_maximum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
Returns the smallest local maximumw for a field. This should be a value smaller or equal to that returned by <span class="function">IntlCalendar::getActualMaxmimum, which is in its turn smaller or equal to that returned by <span class="function">IntlCalendar::getMaximum.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
An int representing a field value in the
fieldʼs unit 或者在失败时返回 false
.
范例
示例 #1 Maxima examples
<?php
ini_set('date.timezone', 'UTC');
ini_set('intl.default_locale', 'it_IT');
$cal = new IntlGregorianCalendar(2013, 3 /* April */, 6);
var_dump(
$cal->getLeastMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), // 28
$cal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), // 30
$cal->getMaximum(IntlCalendar::FIELD_DAY_OF_MONTH) // 31
);
以上例程会输出:
int(28)
int(30)
int(31)
参见
- IntlCalendar::getActualMaximum
- IntlCalendar::getMaximum
- IntlCalendar::getGreatestMinimum
IntlCalendar::getLocale
Get the locale associated with the object
说明
面向对象风格
public <span
class="type">stringfalse <span
class="methodname">IntlCalendar::getLocale ( <span
class="methodparam">int $localeType
)
过程化风格
string<span
class="type">false <span
class="methodname">intlcal_get_locale ( <span
class="methodparam">IntlCalendar $cal
, int
$localeType
)
Returns the locale used by this calendar object.
参数
cal
The IntlCalendar resource.
localeType
Whether to fetch the actual locale (the locale from which the calendar
data originates, with Locale::ACTUAL_LOCALE
) or the valid locale,
i.e., the most specific locale supported by ICU relatively to the
requested locale – see Locale::VALID_LOCALE
. From the most general
to the most specific, the locales are ordered in this fashion – actual
locale, valid locale, requested locale.
返回值
A locale string 或者在失败时返回 false
.
范例
示例 #1 IntlCalendar::getLocale
<?php
$cal = IntlCalendar::createInstance(IntlTimeZone::getGMT(), 'en_US_CALIFORNIA');
var_dump(
$cal->getLocale(Locale::ACTUAL_LOCALE),
$cal->getLocale(Locale::VALID_LOCALE)
);
以上例程会输出:
string(2) "en"
string(5) "en_US"
IntlCalendar::getMaximum
Get the global maximum value for a field
说明
面向对象风格
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getMaximum ( <span
class="methodparam">int $field
)
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_maximum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
Gets the global maximum for a field, in this specific calendar. This value is larger or equal to that returned by <span class="function">IntlCalendar::getActualMaximum, which is in its turn larger or equal to that returned by <span class="function">IntlCalendar::getLeastMaximum.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
An int representing a field value in the
fieldʼs unit 或者在失败时返回 false
.
参见
- IntlCalendar::getActualMaximum
- IntlCalendar::getLeastMaximum
- IntlCalendar::getMinimum
IntlCalendar::getMinimalDaysInFirstWeek
Get minimal number of days the first week in a year or month can have
说明
面向对象风格
public <span class="type">intfalse <span class="methodname">IntlCalendar::getMinimalDaysInFirstWeek ( void )
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_minimal_days_in_first_week (
IntlCalendar
$cal
)
Returns the smallest number of days the first week of a year or month must have in the new year or month. For instance, in the Gregorian calendar, if this value is 1, then the first week of the year will necessarily include January 1st, while if this value is 7, then the week with January 1st will be the first week of the year only if the day of the week for January 1st matches the day of the week returned by <span class="function">IntlCalendar::getFirstDayOfWeek; otherwise it will be the previous yearʼs last week.
参数
cal
The IntlCalendar resource.
返回值
An int representing a number of days
或者在失败时返回 false
.
范例
示例 #1 <span class="function">IntlCalendar::getMinimalDaysInFirstWeek
<?php
ini_set('date.timezone', 'UTC');
ini_set('intl.default_locale', 'en_US');
$cal = new IntlGregorianCalendar(2013, 0 /* January */, 2);
var_dump(IntlDateFormatter::formatObject($cal, 'cccc')); // Wednesday
var_dump($cal->getMinimalDaysInFirstWeek(), // 1
$cal->getFirstDayofWeek()); // 1 (Sunday)
// Week 1 of 2013
var_dump(IntlDateFormatter::formatObject($cal, "'Week 'w' of 'Y"));
$cal->setMinimalDaysInFirstWeek(4);
// Still Week 1 of 2013 (1st week has 5 days in the new year)
var_dump(IntlDateFormatter::formatObject($cal, "'Week 'w' of 'Y"));
$cal->setMinimalDaysInFirstWeek(6);
// Week 53 of 2012
var_dump(IntlDateFormatter::formatObject($cal, "'Week 'w' of 'Y"));
以上例程会输出:
string(9) "Wednesday"
int(1)
int(1)
string(14) "Week 1 of 2013"
string(14) "Week 1 of 2013"
string(15) "Week 53 of 2012"
IntlCalendar::getMinimum
Get the global minimum value for a field
说明
面向对象风格
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getMinimum ( <span
class="methodparam">int $field
)
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_minimum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
Gets the global minimum for a field, in this specific calendar. This value is smaller or equal to that returned by <span class="function">IntlCalendar::getActualMinimum, which is in its turn smaller or equal to that returned by <span class="function">IntlCalendar::getGreatestMinimum. For the Gregorian calendar, these three functions always return the same value (for each field).
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
An int representing a value for the given
field in the fieldʼs unit 或者在失败时返回 false
.
IntlCalendar::getNow
Get number representing the current time
说明
面向对象风格
public <span class="modifier">static float <span class="methodname">IntlCalendar::getNow ( <span class="methodparam">void )
过程化风格
float <span class="methodname">intlcal_get_now ( <span class="methodparam">void )
The number of milliseconds that have passed since the reference date. This number is derived from the system time.
参数
此函数没有参数。
返回值
A float representing a number of milliseconds since the epoch, not counting leap seconds.
范例
示例 #1 IntlCalendar::getNow
<?php
$formatter = IntlDateFormatter::create('es_ES',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'Europe/Madrid');
$val = IntlCalendar::getNow();
var_dump($val);
echo $formatter->format(IntlCalendar::getNow() / 1000.), "\n";
以上例程会输出:
float(1371425814666)
lunes, 17 de junio de 2013 01:36:54 Hora de verano de Europa central
IntlCalendar::getRepeatedWallTimeOption
Get behavior for handling repeating wall time
说明
面向对象风格
public int <span class="methodname">IntlCalendar::getRepeatedWallTimeOption ( void )
过程化风格
int <span
class="methodname">intlcal_get_repeated_wall_time_option (
IntlCalendar
$cal
)
Gets the current strategy for dealing with wall times that are repeated
whenever the clock is set back during dailight saving time end
transitions. The default value is IntlCalendar::WALLTIME_LAST
.
This function requires ICU 4.9 or later.
参数
cal
The IntlCalendar resource.
返回值
One of the constants IntlCalendar::WALLTIME_FIRST
or
IntlCalendar::WALLTIME_LAST
.
范例
示例 #1 <span class="function">IntlCalendar::getRepeatedWallTimeOption
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'en_US');
ini_set('intl.error_level', E_WARNING);
//On October 27th at 0200, the clock goes back 1 hour and from GMT+01 to GMT+00
$cal = new IntlGregorianCalendar(2013, 9 /* October */, 27, 1, 30);
var_dump($cal->getRepeatedWalltimeOption()); // 0 WALLTIME_LAST
$formatter = IntlDateFormatter::create(
NULL,
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'UTC'
);
var_dump($formatter->format($cal->getTime() / 1000.));
$cal->setRepeatedWalltimeOption(IntlCalendar::WALLTIME_FIRST);
var_dump($cal->getRepeatedWalltimeOption()); // 1 WALLTIME_FIRST
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 1);
var_dump($formatter->format($cal->getTime() / 1000.));
以上例程会输出:
int(0)
string(42) "Sunday, October 27, 2013 at 1:30:00 AM GMT"
int(1)
string(43) "Sunday, October 27, 2013 at 12:30:00 AM GMT"
参见
- <span class="methodname">IntlCalendar::getSkippedWallTimeOption
- <span class="methodname">IntlCalendar::setSkippedWallTimeOption
- <span class="methodname">IntlCalendar::setRepeatedWallTimeOption
IntlCalendar::getSkippedWallTimeOption
Get behavior for handling skipped wall time
说明
面向对象风格
public int <span class="methodname">IntlCalendar::getSkippedWallTimeOption ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">intlcal_get_skipped_wall_time_option (
IntlCalendar
$cal
)
Gets the current strategy for dealing with wall times that are skipped
whenever the clock is forwarded during dailight saving time start
transitions. The default value is IntlCalendar::WALLTIME_LAST
.
The calendar must be lenient for this option to have any effect, otherwise attempting to set a non-existing time will cause an error.
This function requires ICU 4.9 or later.
参数
cal
The IntlCalendar resource.
返回值
One of the constants IntlCalendar::WALLTIME_FIRST
,
IntlCalendar::WALLTIME_LAST
or
IntlCalendar::WALLTIME_NEXT_VALID
.
范例
示例 #1 <span class="function">IntlCalendar::getSkippedWallTimeOption
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'en_US');
ini_set('intl.error_level', E_WARNING);
//On March 31st at 0100, the clock goes forward 1 hour and from GMT+00 to GMT+01
$cal = new IntlGregorianCalendar(2013, 2 /* March */, 31, 1, 30);
var_dump(
$cal->isLenient(), // true
$cal->getSkippedWalltimeOption() // 0 WALLTIME_LAST
);
$formatter = IntlDateFormatter::create(
NULL,
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'UTC'
);
var_dump($formatter->format($cal->getTime() / 1000));
$cal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_FIRST);
var_dump($cal->getSkippedWalltimeOption()); // 1 WALLTIME_FIRST
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 1);
var_dump($formatter->format($cal->getTime() / 1000));
$cal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_NEXT_VALID);
var_dump($cal->getSkippedWalltimeOption()); // 2 WALLTIME_NEXT_VALID
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 1);
var_dump($formatter->format($cal->getTime() / 1000));
以上例程会输出:
bool(true)
int(0)
string(40) "Sunday, March 31, 2013 at 1:30:00 AM GMT"
int(1)
string(41) "Sunday, March 31, 2013 at 12:30:00 AM GMT"
int(2)
string(40) "Sunday, March 31, 2013 at 1:00:00 AM GMT"
参见
- <span class="methodname">IntlCalendar::getRepeatedWallTimeOption
- <span class="methodname">IntlCalendar::setSkippedWallTimeOption
- <span class="methodname">IntlCalendar::setRepeatedWallTimeOption
IntlCalendar::getTime
Get time currently represented by the object
说明
面向对象风格
public float IntlCalendar::getTime ( <span class="methodparam">void )
过程化风格
float <span
class="methodname">intlcal_get_time ( <span
class="methodparam">IntlCalendar $cal
)
Returns the time associated with this object, expressed as the number of milliseconds since the epoch.
参数
cal
The IntlCalendar resource.
返回值
A float representing the number of milliseconds elapsed since the reference time (1 Jan 1970 00:00:00 UTC).
范例
示例 #1 IntlCalendar::getTime
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'en_US');
$cal = new IntlGregorianCalendar(2013, 4 /* May */, 1, 0, 0, 0);
$time = $cal->getTime();
var_dump($time, $time / 1000 == strtotime('2013-05-01 00:00:00')); //true
以上例程会输出:
float(1367362800000)
bool(true)
参见
- IntlCalendar::getNow
IntlCalendar::getTimeZone
Get the objectʼs timezone
说明
面向对象风格
public <span class="type">IntlTimeZone <span class="methodname">IntlCalendar::getTimeZone ( <span class="methodparam">void )
过程化风格
IntlTimeZone <span
class="methodname">intlcal_get_time_zone ( <span
class="methodparam">IntlCalendar $cal
)
Returns the IntlTimeZone object associated with this calendar.
参数
cal
The IntlCalendar resource.
返回值
An IntlTimeZone object corresponding to the one used internally in this object.
范例
示例 #1 IntlCalendar::getTimeZone
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'en_US');
$cal = IntlCalendar::createInstance();
print_r($cal->getTimeZone());
$cal->setTimeZone('UTC');
print_r($cal->getTimeZone());
$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00 GMT+03:33');
print_r($cal->getTimeZone());
以上例程会输出:
IntlTimeZone Object
(
[valid] => 1
[id] => Europe/Lisbon
[rawOffset] => 0
[currentOffset] => 3600000
)
IntlTimeZone Object
(
[valid] => 1
[id] => UTC
[rawOffset] => 0
[currentOffset] => 0
)
IntlTimeZone Object
(
[valid] => 1
[id] => GMT+03:33
[rawOffset] => 12780000
[currentOffset] => 12780000
)
参见
- IntlCalendar::setTimeZone
- IntlCalendar::createInstance
- IntlGregorianCalendar::__construct
IntlCalendar::getType
Get the calendar type
说明
面向对象风格
public string IntlCalendar::getType ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">intlcal_get_type ( <span
class="methodparam">IntlCalendar $cal
)
A string describing the type of this calendar. This is one of the valid values for the calendar keyword value 'calendar'.
参数
cal
The IntlCalendar resource.
返回值
A string representing the calendar type, such as 'gregorian', 'islamic', etc.
范例
示例 #1 IntlCalendar::getType
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'en_US');
$cal = IntlCalendar::createInstance(NULL, '@calendar=ethiopic-amete-alem');
var_dump($cal->getType());
$cal = new IntlGregorianCalendar();
var_dump($cal->getType());
以上例程会输出:
string(19) "ethiopic-amete-alem"
string(9) "gregorian"
IntlCalendar::getWeekendTransition
Get time of the day at which weekend begins or ends
说明
面向对象风格
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getWeekendTransition ( <span
class="methodparam">string $dayOfWeek
)
过程化风格
int<span
class="type">false <span
class="methodname">intlcal_get_weekend_transition ( <span
class="methodparam">IntlCalendar $cal
, string
$dayOfWeek
)
Returns the number of milliseconds after midnight at which the weekend begins or ends.
This is only applicable for days of the week for which <span
class="function">IntlCalendar::getDayOfWeekType returns either
IntlCalendar::DOW_TYPE_WEEKEND_OFFSET
or
IntlCalendar::DOW_TYPE_WEEKEND_CEASE
. Calling this function for
other days of the week is an error condition.
This function requires ICU 4.4 or later.
参数
cal
The IntlCalendar resource.
dayOfWeek
One of the constants IntlCalendar::DOW_SUNDAY
,
IntlCalendar::DOW_MONDAY
, …, IntlCalendar::DOW_SATURDAY
.
返回值
The number of milliseconds into the day at which the weekend begins or
ends 或者在失败时返回 false
.
范例
See example on <span class="function">IntlCalendar::getDayOfWeekType.
IntlCalendar::inDaylightTime
Whether the objectʼs time is in Daylight Savings Time
说明
面向对象风格
public bool IntlCalendar::inDaylightTime ( <span class="methodparam">void )
过程化风格
bool <span
class="methodname">intlcal_in_daylight_time ( <span
class="methodparam">IntlCalendar $cal
)
Whether, for the instant represented by this object and for this objectʼs timezone, daylight saving time is in place.
参数
cal
The IntlCalendar resource.
返回值
Returns true
if the date is in Daylight Savings Time, false
otherwise. The value false
may also be returned on failure, for
instance after specifying invalid field values on non-lenient mode; use
exceptions or query <span
class="function">intl_get_error_code to disambiguate.
范例
示例 #1 IntlCalendar::inDaylightTime
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'pt_PT');
$cal = new IntlGregorianCalendar(2013, 6 /* July */, 1, 4, 56, 31);
var_dump($cal->inDaylightTime()); // true
$cal->set(IntlCalendar::FIELD_MONTH, 11 /* December */);
var_dump($cal->inDaylightTime()); // false
//DST end transition on 2013-10-27 at 0200 (wall time back 1 hour)
$cal = new IntlGregorianCalendar(2013, 9 /* October */, 27, 1, 30, 0);
var_dump($cal->inDaylightTime()); // false (default WALLTIME_LAST)
$cal->setRepeatedWallTimeOption(IntlCalendar::WALLTIME_FIRST);
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 1); // force time recalculation
var_dump($cal->inDaylightTime()); // true
IntlCalendar::isEquivalentTo
Whether another calendar is equal but for a different time
说明
面向对象风格
public bool
IntlCalendar::isEquivalentTo ( <span
class="methodparam">IntlCalendar
$other
)
过程化风格
bool <span
class="methodname">intlcal_is_equivalent_to ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
Returns whether this and the given object are equivalent for all purposes except as to the time they have set. The locales do not have to match, as long as no change in behavior results from such mismatch. This includes the timezone, whether the lenient mode is set, the repeated and skipped wall time settings, the days of the week when the weekend starts and ceases and the times where such transitions occur. It may also include other calendar specific settings, such as the Gregorian/Julian transition instant.
参数
cal
The IntlCalendar resource.
other
The other calendar against which the comparison is to be made.
返回值
Assuming there are no argument errors, returns true
if the
calendars are equivalent except possibly for their set time.
范例
示例 #1 IntlCalendar::isEquivalentTo
<?php
$cal1 = IntlCalendar::createInstance('Europe/Lisbon', 'pt_PT');
$cal2 = IntlCalendar::createInstance('Europe/Lisbon', 'es_ES');
$cal2->clear();
var_dump($cal1->isEquivalentTo($cal2)); // true
$cal3 = IntlCalendar::createInstance('Europe/Lisbon', 'en_US');
var_dump($cal1->isEquivalentTo($cal3)); // false
var_dump($cal1->getFirstDayOfWeek(), // 2 (Monday)
$cal3->getFirstDayOfWeek()); // 1 (Sunday)
以上例程会输出:
bool(true)
bool(false)
int(2)
int(1)
参见
- IntlCalendar::equals
IntlCalendar::isLenient
Whether date/time interpretation is in lenient mode
说明
面向对象风格
public bool IntlCalendar::isLenient ( <span class="methodparam">void )
过程化风格
bool <span
class="methodname">intlcal_is_lenient ( <span
class="methodparam">IntlCalendar $cal
)
Returns whether the current date/time interpretations is lenient (the default). If that is case, some out of range values for fields will be accepted instead of raising an error.
参数
cal
The IntlCalendar resource.
返回值
A bool representing whether the calendar is set to lenient mode.
范例
示例 #1 IntlCalendar::isLenient
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'pt_PT');
ini_set('intl.use_exceptions', '1');
$cal = new IntlGregorianCalendar(2013, 6 /* July */, 1);
var_dump(IntlDateFormatter::formatObject($cal), // 01/07/2013, 00:00:00
$cal->isLenient()); // true
$cal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 33);
var_dump(IntlDateFormatter::formatObject($cal)); // 02/08/2013, 00:00:00
$cal->setLenient(false);
var_dump($cal->isLenient()); // false
$cal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 33);
var_dump(IntlDateFormatter::formatObject($cal)); // error
以上例程会输出:
string(20) "01/07/2013, 00:00:00"
bool(true)
string(20) "02/08/2013, 00:00:00"
bool(false)
Fatal error: Uncaught exception 'IntlException' with message 'datefmt_format_object: error obtaining instant from IntlCalendar' in /home/foobar/example.php:16
Stack trace:
#0 /home/foobar/example.php(16): IntlDateFormatter::formatObject(Object(IntlGregorianCalendar))
#1 {main}
thrown in /home/foobar/example.php on line 16
IntlCalendar::isSet
Whether a field is set
说明
面向对象风格
public bool
IntlCalendar::isSet ( <span
class="methodparam">int $field
)
过程化风格
bool <span
class="methodname">intlcal_is_set ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
Returns whether a field is set (as opposed to clear). Set fields take priority over unset fields and their default values when the date/time is being calculated. Fields set later take priority over fields set earlier.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
返回值
Assuming there are no argument errors, returns true
if the field
is set.
范例
See the example on IntlCalendar::clear.
参见
- IntlCalendar::clear
- IntlCalendar::set
IntlCalendar::isWeekend
Whether a certain date/time is in the weekend
说明
面向对象风格
public bool
IntlCalendar::isWeekend ([ <span
class="methodparam">float $date
<span
class="initializer"> = NULL ] )
过程化风格
bool <span
class="methodname">intlcal_is_weekend ( <span
class="methodparam">IntlCalendar $cal
[, float
$date
= NULL ] )
Returns whether either the obejctʼs current time or the provided timestamp occur during a weekend in this objectʼs calendar system.
This function requires ICU 4.4 or later.
参数
cal
The IntlCalendar resource.
date
An optional timestamp representing the number of milliseconds since the
epoch, excluding leap seconds. If null
, this objectʼs current time
is used instead.
返回值
A bool indicating whether the given or this objectʼs time occurs in a weekend.
The value false
may also be returned on failure, for instance
after giving a date out of bounds on non-lenient mode; use
exceptions or query <span
class="function">intl_get_error_code to disambiguate.
范例
示例 #1 IntlCalendar::isWeekend
<?php
ini_set('date.timezone', 'Europe/Lisbon');
$cal = new IntlGregorianCalendar(NULL, 'en_US');
$cal->set(2013, 6 /* July */, 7); // a Sunday
var_dump($cal->isWeekend()); // true
var_dump($cal->isWeekend(strtotime('2013-07-01 00:00:00'))); // false, Monday
$cal = new IntlGregorianCalendar(NULL, 'ar_SA');
$cal->set(2013, 6 /* July */, 7); // a Sunday
var_dump($cal->isWeekend()); // false, Sunday not in weekend in this calendar
参见
- IntlCalendar::getDayOfWeekType
- IntlCalendar::getWeekendTransition
IntlCalendar::roll
Add value to field without carrying into more significant fields
说明
面向对象风格
public bool
IntlCalendar::roll ( <span
class="methodparam">int $field
,
mixed
$amountOrUpOrDown
)
过程化风格
bool <span
class="methodname">intlcal_roll ( <span
class="methodparam">IntlCalendar $cal
, int
$field
, <span
class="type">mixed $amountOrUpOrDown
)
Adds a (signed) amount to a field. The difference with respect to <span class="function">IntlCalendar::add is that when the field value overflows, it does not carry into more significant fields.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
amountOrUpOrDown
The (signed) amount to add to the field, true
for rolling up
(adding 1), or false
for rolling down (subtracting 1).
返回值
Returns true
on success or false
on failure.
范例
示例 #1 IntlCalendar::roll
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'pt_PT');
$cal = new IntlGregorianCalendar(2013, 5 /* June */, 30);
$cal->add(IntlCalendar::FIELD_DAY_OF_MONTH, 1);
var_dump(IntlDateFormatter::formatObject($cal)); // "01/07/2013, 00:00:00"
$cal->set(2013, 5 /* June */, 30);
$cal->roll(IntlCalendar::FIELD_DAY_OF_MONTH, true); // roll up, same as rolling +1
var_dump(IntlDateFormatter::formatObject($cal)); // "01/06/2013, 00:00:00"
以上例程会输出:
string(20) "01/07/2013, 00:00:00"
string(20) "01/06/2013, 00:00:00"
参见
- IntlCalendar::add
- IntlCalendar::set
IntlCalendar::set
Set a time field or several common fields at once
说明
面向对象风格
public bool
IntlCalendar::set ( <span
class="methodparam">int $field
,
int $value
)
public bool
IntlCalendar::set ( <span
class="methodparam">int $year
, <span
class="methodparam">int $month
[,
int
$dayOfMonth
= NULL [, <span
class="methodparam">int $hour
<span
class="initializer"> = NULL [, <span
class="methodparam">int $minute
<span
class="initializer"> = NULL [, <span
class="methodparam">int $second
<span
class="initializer"> = NULL ]]]] )
过程化风格
bool <span
class="methodname">intlcal_set ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $field
,
int $value
)
bool <span
class="methodname">intlcal_set ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $year
, <span
class="methodparam">int $month
[,
int
$dayOfMonth
= NULL [, <span
class="methodparam">int $hour
<span
class="initializer"> = NULL [, <span
class="methodparam">int $minute
<span
class="initializer"> = NULL [, <span
class="methodparam">int $second
<span
class="initializer"> = NULL ]]]] )
Sets either a specific field to the given value, or sets at once several common fields. The range of values that are accepted depend on whether the calendar is using the lenient mode.
For fields that conflict, the fields that are set later have priority.
This method cannot be called with exactly four arguments.
参数
cal
The IntlCalendar resource.
field
One of the IntlCalendar date/time
field constants.
These are integer values between 0 and
IntlCalendar::FIELD_COUNT
.
value
The new value of the given field.
year
The new value for IntlCalendar::FIELD_YEAR
.
month
The new value for IntlCalendar::FIELD_MONTH
. The month sequence is
zero-based, i.e., January is represented by 0, February by 1, …,
December is 11 and Undecember (if the calendar has it) is 12.
dayOfMonth
The new value for IntlCalendar::FIELD_DAY_OF_MONTH
.
hour
The new value for IntlCalendar::FIELD_HOUR_OF_DAY
.
minute
The new value for IntlCalendar::FIELD_MINUTE
.
second
The new value for IntlCalendar::FIELD_SECOND
.
返回值
Returns true
on success and false
on failure.
范例
示例 #1 IntlCalendar::set
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'pt_PT');
//Calls made later have priority
$cal = new IntlGregorianCalendar(2013, 6 /* July */, 1);
$cal->set(IntlCalendar::FIELD_YEAR, 2012);
$cal->set(IntlCalendar::FIELD_EXTENDED_YEAR, 2011);
var_dump(IntlDateFormatter::formatObject($cal));
$cal = new IntlGregorianCalendar(2013, 6 /* July */, 1);
$cal->set(IntlCalendar::FIELD_YEAR, 2012);
$cal->set(IntlCalendar::FIELD_EXTENDED_YEAR, 2011);
//the time has not been recalculated yet. If we clear the extended year,
//the year set before will be used
$cal->clear(IntlCalendar::FIELD_EXTENDED_YEAR);
var_dump(IntlDateFormatter::formatObject($cal));
以上例程会输出:
string(20) "01/07/2011, 00:00:00"
string(20) "01/07/2012, 00:00:00"
参见
- IntlCalendar::get
- IntlCalendar::add
- IntlCalendar::roll
IntlCalendar::setFirstDayOfWeek
Set the day on which the week is deemed to start
说明
面向对象风格
public bool
IntlCalendar::setFirstDayOfWeek ( <span
class="methodparam">int $dayOfWeek
)
过程化风格
bool <span
class="methodname">intlcal_set_first_day_of_week ( <span
class="methodparam">IntlCalendar $cal
, int
$dayOfWeek
)
Defines the day of week deemed to start the week. This affects the
behavior of fields that depend on the concept of week start and end such
as IntlCalendar::FIELD_WEEK_OF_YEAR
and
IntlCalendar::FIELD_YEAR_WOY
.
参数
cal
The IntlCalendar resource.
dayOfWeek
One of the constants IntlCalendar::DOW_SUNDAY
,
IntlCalendar::DOW_MONDAY
, …, IntlCalendar::DOW_SATURDAY
.
返回值
Returns true
on success. Failure can only happen due to invalid
parameters.
范例
示例 #1 <span class="function">IntlCalendar::setFirstDayOfWeek
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'es_ES');
$cal = IntlCalendar::createInstance();
$cal->set(2013, 5 /* June */, 30); // A Sunday
var_dump($cal->getFirstDayOfWeek()); // 2 (Monday)
echo IntlDateFormatter::formatObject($cal, <<<EOD
'local day of week: 'cc'
week of month : 'W'
week of year : 'ww
EOD
), "\n";
$cal->setFirstDayOfWeek(IntlCalendar::DOW_SUNDAY);
echo IntlDateFormatter::formatObject($cal, <<<EOD
'local day of week: 'cc'
week of month : 'W'
week of year : 'ww
EOD
), "\n";
以上例程会输出:
int(2)
local day of week: 7
week of month : 4
week of year : 26
local day of week: 1
week of month : 5
week of year : 27
IntlCalendar::setLenient
Set whether date/time interpretation is to be lenient
说明
面向对象风格
public bool
IntlCalendar::setLenient ( <span
class="methodparam">bool $isLenient
)
过程化风格
bool <span
class="methodname">intlcal_set_lenient ( <span
class="methodparam">IntlCalendar $cal
, bool
$isLenient
)
Defines whether the calendar is ‘lenient mode’. In such a mode, some of out-of-bounds values for some fields are accepted, the behavior being similar to that of IntlCalendar::add (i.e., the value wraps around, carrying into more significant fields each time). If the lenient mode is off, then such values will generate an error.
参数
cal
The IntlCalendar resource.
isLenient
Use true
to activate the lenient mode; false
otherwise.
返回值
Returns true
on success. Failure can only happen due to invalid
parameters.
范例
See the example in <span class="function">IntlCalendar::isLenient.
IntlCalendar::setMinimalDaysInFirstWeek
Set minimal number of days the first week in a year or month can have
说明
面向对象风格
public bool
IntlCalendar::setMinimalDaysInFirstWeek
( int
$minimalDays
)
过程化风格
bool <span
class="methodname">intlcal_set_minimal_days_in_first_week (
IntlCalendar
$cal
, int
$minimalDays
)
Sets the smallest number of days the first week of a year or month must have in the new year or month. For instance, in the Gregorian calendar, if this value is 1, then the first week of the year will necessarily include January 1st, while if this value is 7, then the week with January 1st will be the first week of the year only if the day of the week for January 1st matches the day of the week returned by <span class="function">IntlCalendar::getFirstDayOfWeek; otherwise it will be the previous yearʼs last week.
参数
cal
The IntlCalendar resource.
minimalDays
The number of minimal days to set.
返回值
true
on success, false
on failure.
IntlCalendar::setRepeatedWallTimeOption
Set behavior for handling repeating wall times at negative timezone offset transitions
说明
面向对象风格
public bool
IntlCalendar::setRepeatedWallTimeOption
( int
$wallTimeOption
)
过程化风格
bool <span
class="methodname">intlcal_set_repeated_wall_time_option (
IntlCalendar
$cal
, int
$wallTimeOption
)
Sets the current strategy for dealing with wall times that are repeated
whenever the clock is set back during dailight saving time end
transitions. The default value is IntlCalendar::WALLTIME_LAST
(take the post-DST instant). The other possible value is
IntlCalendar::WALLTIME_FIRST
(take the instant that occurs during
DST).
This function requires ICU 4.9 or later.
参数
cal
The IntlCalendar resource.
wallTimeOption
One of the constants IntlCalendar::WALLTIME_FIRST
or
IntlCalendar::WALLTIME_LAST
.
返回值
Returns true
on success. Failure can only happen due to invalid
parameters.
范例
See the example on <span class="function">IntlCalendar::getRepeatedWallTimeOption.
参见
- <span class="methodname">intlCalendar::getRepeatedWallTimeOption
- <span class="methodname">intlCalendar::setSkippedWallTimeOption
- <span class="methodname">intlCalendar::getSkippedWallTimeOption
IntlCalendar::setSkippedWallTimeOption
Set behavior for handling skipped wall times at positive timezone offset transitions
说明
面向对象风格
public bool
IntlCalendar::setSkippedWallTimeOption (
int
$wallTimeOption
)
过程化风格
bool <span
class="methodname">intlcal_set_skipped_wall_time_option (
IntlCalendar
$cal
, int
$wallTimeOption
)
Sets the current strategy for dealing with wall times that are skipped
whenever the clock is forwarded during dailight saving time start
transitions. The default value is IntlCalendar::WALLTIME_LAST
(take it as being the same instant as the one when the wall time is one
hour more). Alternative values are IntlCalendar::WALLTIME_FIRST
(same instant as the one with a wall time of one hour less) and
IntlCalendar::WALLTIME_NEXT_VALID
(same instant as when DST
begins).
This affects only the instant represented by the calendar (as reported by IntlCalendar::getTime), the field values will not be rewritten accordingly.
The calendar must be lenient for this option to have any effect, otherwise attempting to set a non-existing time will cause an error.
This function requires ICU 4.9 or later.
参数
cal
The IntlCalendar resource.
wallTimeOption
One of the constants IntlCalendar::WALLTIME_FIRST
,
IntlCalendar::WALLTIME_LAST
or
IntlCalendar::WALLTIME_NEXT_VALID
.
返回值
Returns true
on success. Failure can only happen due to invalid
parameters.
范例
See the example on <span class="function">IntlCalendar::getSkippedWallTimeOption.
参见
- <span class="methodname">intlCalendar::getSkippedWallTimeOption
- <span class="methodname">intlCalendar::setRepeatedWallTimeOption
- <span class="methodname">intlCalendar::getRepeatedWallTimeOption
IntlCalendar::setTime
Set the calendar time in milliseconds since the epoch
说明
面向对象风格
public bool
IntlCalendar::setTime ( <span
class="methodparam">float $date
)
过程化风格
bool <span
class="methodname">intlcal_set_time ( <span
class="methodparam">IntlCalendar $cal
, float
$date
)
Sets the instant represented by this object. The instant is represented by a float whose value should be an integer number of milliseconds since the epoch (1 Jan 1970 00:00:00.000 UTC), ignoring leap seconds. All the field values will be recalculated accordingly.
参数
cal
The IntlCalendar resource.
date
An instant represented by the number of number of milliseconds between
such instant and the epoch, ignoring leap seconds.
返回值
Returns true
on success and false
on failure.
范例
示例 #1 IntlCalendar::setTime
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'fr_FR');
$cal = new IntlGregorianCalendar(2013, 5 /* May */, 1, 12, 0, 0);
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
/* In Europe/Lisbon, on 2013-10-27 at 0200, the clock goes back one hour and
the timezone from UTC+01 to UTC+00 */
$cal->setTime(strtotime('2013-10-27 00:30:00 UTC') * 1000.);
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
$cal->setTime(strtotime('2013-10-27 01:30:00 UTC') * 1000.);
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
以上例程会输出:
samedi 1 juin 2013 12:00:00 heure avancée d’Europe de l’Ouest
dimanche 27 octobre 2013 01:30:00 heure avancée d’Europe de l’Ouest
dimanche 27 octobre 2013 01:30:00 heure normale d’Europe de l’Ouest
IntlCalendar::setTimeZone
Set the timezone used by this calendar
说明
面向对象风格
public bool
IntlCalendar::setTimeZone ( <span
class="methodparam">mixed $timeZone
)
过程化风格
bool <span
class="methodname">intlcal_set_time_zone ( <span
class="methodparam">IntlCalendar $cal
, mixed
$timeZone
)
Defines a new timezone for this calendar. The time represented by the object is preserved to the detriment of the field values.
参数
cal
The IntlCalendar resource.
timeZone
The new timezone to be used by this calendar. It can be specified in the
following ways:
-
null
, in which case the default timezone will be used, as specified in the ini setting date.timezone or through the function <span class="function">date_default_timezone_set and as returned by date_default_timezone_get. -
An IntlTimeZone, which will be used directly.
-
A DateTimeZone. Its identifier will be extracted and an ICU timezone object will be created; the timezone will be backed by ICUʼs database, not PHPʼs.
-
A string, which should be a valid ICU timezone identifier. See <span class="function">IntlTimeZone::createTimeZoneIDEnumeration. Raw offsets such as "GMT+08:30" are also accepted.
返回值
Returns true
on success and false
on failure.
范例
示例 #1 IntlCalendar::setTimeZone
<?php
ini_set('date.timezone', 'Europe/Lisbon');
ini_set('intl.default_locale', 'es_ES');
$cal = new IntlGregorianCalendar(2013, 5 /* May */, 1, 12, 0, 0);
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
echo "(instant {$cal->getTime()})\n";
$cal->setTimeZone(IntlTimeZone::getGMT());
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
echo "(instant {$cal->getTime()})\n";
$cal->setTimeZone('GMT+03:33');
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
echo "(instant {$cal->getTime()})\n";
以上例程会输出:
sábado, 1 de junio de 2013 12:00:00 Hora de verano de Europa occidental
(instant 1370084400000)
sábado, 1 de junio de 2013 11:00:00 GMT
(instant 1370084400000)
sábado, 1 de junio de 2013 14:33:00 GMT+03:33
(instant 1370084400000)
IntlCalendar::toDateTime
Convert an IntlCalendar into a DateTime object
说明
面向对象风格
public DateTime IntlCalendar::toDateTime ( <span class="methodparam">void )
过程化风格
DateTime <span
class="methodname">intlcal_to_date_time ( <span
class="methodparam">IntlCalendar $cal
)
Create a DateTime object that represents the same instant (up to second precision, with a rounding error of less than 1 second) and has an analog timezone to this object (the difference being DateTimeʼs timezone will be backed by PHPʼs timezone while IntlCalendarʼs timezone is backed by ICUʼs).
参数
cal
The IntlCalendar resource.
返回值
A DateTime object with the same timezone
as this object (though using PHPʼs database instead of ICUʼs) and the
same time, except for the smaller precision (second precision instead of
millisecond). Returns false
on failure.
范例
示例 #1 IntlCalendar::toDateTime
<?php
ini_set('date.timezone', 'UTC');
ini_set('intl.default_locale', 'pt_PT');
$cal = IntlCalendar::createInstance('Europe/Lisbon'); //current time
$dt = $cal->toDateTime();
print_r($dt);
以上例程会输出:
DateTime Object
(
[date] => 2013-07-02 00:29:13
[timezone_type] => 3
[timezone] => Europe/Lisbon
)
参见
- IntlCalendar::fromDateTime
- IntlCalendar::getTime
- IntlCalendar::createInstance
- DateTime:__construct
简介
类摘要
IntlGregorianCalendar
class IntlGregorianCalendar <span class="ooclass"> extends IntlCalendar {
/* 继承的常量 */
const int
IntlCalendar::FIELD_ERA
= 0 ;
const int
IntlCalendar::FIELD_YEAR
= 1 ;
const int
IntlCalendar::FIELD_MONTH
= 2 ;
const int
IntlCalendar::FIELD_WEEK_OF_YEAR
= 3
;
const int
IntlCalendar::FIELD_WEEK_OF_MONTH
=
4 ;
const int
IntlCalendar::FIELD_DATE
= 5 ;
const int
IntlCalendar::FIELD_DAY_OF_YEAR
= 6
;
const int
IntlCalendar::FIELD_DAY_OF_WEEK
= 7
;
const int
IntlCalendar::FIELD_DAY_OF_WEEK_IN_MONTH
=
8 ;
const int
IntlCalendar::FIELD_AM_PM
= 9 ;
const int
IntlCalendar::FIELD_HOUR
= 10 ;
const int
IntlCalendar::FIELD_HOUR_OF_DAY
= 11
;
const int
IntlCalendar::FIELD_MINUTE
= 12 ;
const int
IntlCalendar::FIELD_SECOND
= 13 ;
const int
IntlCalendar::FIELD_MILLISECOND
= 14
;
const int
IntlCalendar::FIELD_ZONE_OFFSET
= 15
;
const int
IntlCalendar::FIELD_DST_OFFSET
= 16
;
const int
IntlCalendar::FIELD_YEAR_WOY
= 17 ;
const int
IntlCalendar::FIELD_DOW_LOCAL
= 18 ;
const int
IntlCalendar::FIELD_EXTENDED_YEAR
=
19 ;
const int
IntlCalendar::FIELD_JULIAN_DAY
= 20
;
const int
IntlCalendar::FIELD_MILLISECONDS_IN_DAY
=
21 ;
const int
IntlCalendar::FIELD_IS_LEAP_MONTH
=
22 ;
const int
IntlCalendar::FIELD_FIELD_COUNT
=
23 ;
const int
IntlCalendar::FIELD_DAY_OF_MONTH
= 5
;
const int
IntlCalendar::DOW_SUNDAY
= 1 ;
const int
IntlCalendar::DOW_MONDAY
= 2 ;
const int
IntlCalendar::DOW_TUESDAY
= 3 ;
const int
IntlCalendar::DOW_WEDNESDAY
= 4 ;
const int
IntlCalendar::DOW_THURSDAY
= 5 ;
const int
IntlCalendar::DOW_FRIDAY
= 6 ;
const int
IntlCalendar::DOW_SATURDAY
= 7 ;
const int
IntlCalendar::DOW_TYPE_WEEKDAY
= 0 ;
const int
IntlCalendar::DOW_TYPE_WEEKEND
= 1 ;
const int
IntlCalendar::DOW_TYPE_WEEKEND_OFFSET
=
2 ;
const int
IntlCalendar::DOW_TYPE_WEEKEND_CEASE
=
3 ;
const int
IntlCalendar::WALLTIME_FIRST
= 1 ;
const int
IntlCalendar::WALLTIME_LAST
= 0 ;
const int
IntlCalendar::WALLTIME_NEXT_VALID
=
2 ;
/* 方法 */
public <span
class="methodname">__construct ([ <span
class="methodparam">IntlTimeZone $tz
[, string
$locale
]] )
public <span class="type">floatfalse <span class="methodname">getGregorianChange ( <span class="methodparam">void )
public bool
isLeapYear ( <span
class="methodparam">int $year
)
public bool
setGregorianChange ( <span
class="methodparam">float $date
)
/* 继承的方法 */
public bool
IntlCalendar::add ( <span
class="methodparam">int $field
,
int $amount
)
bool <span
class="methodname">intlcal_add ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $field
,
int $amount
)
public bool
IntlCalendar::after ( <span
class="methodparam">IntlCalendar
$other
)
bool <span
class="methodname">intlcal_after ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
public bool
IntlCalendar::before ( <span
class="methodparam">IntlCalendar
$other
)
bool <span
class="methodname">intlcal_before ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
public bool
IntlCalendar::clear ([ <span
class="methodparam">int $field
<span
class="initializer"> = NULL ] )
bool <span
class="methodname">intlcal_clear ( <span
class="methodparam">IntlCalendar $cal
[, int
$field
= NULL ] )
private <span class="methodname">IntlCalendar::__construct ( <span class="methodparam">void )
public <span
class="modifier">static IntlCalendar
IntlCalendar::createInstance ([ <span
class="methodparam">mixed $timeZone
<span
class="initializer"> = NULL [, <span
class="methodparam">string $locale
<span
class="initializer"> = "" ]] )
IntlCalendar <span
class="methodname">intlcal_create_instance ([ <span
class="methodparam">mixed $timeZone
<span
class="initializer"> = NULL [, <span
class="methodparam">string $locale
<span
class="initializer"> = "" ]] )
public bool
IntlCalendar::equals ( <span
class="methodparam">IntlCalendar
$other
)
bool <span
class="methodname">intlcal_equals ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::fieldDifference ( <span
class="methodparam">float $when
,
int $field
)
int<span
class="type">false <span
class="methodname">intlcal_field_difference ( <span
class="methodparam">IntlCalendar $cal
, float
$when
, int
$field
)
public <span
class="modifier">static IntlCalendar
IntlCalendar::fromDateTime ( <span
class="methodparam">mixed $dateTime
)
IntlCalendar <span
class="methodname">intlcal_from_date_time ( <span
class="methodparam">mixed $dateTime
)
public int <span
class="methodname">IntlCalendar::get ( <span
class="methodparam">int $field
)
int <span
class="methodname">intlcal_get ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $field
)
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getActualMaximum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_actual_maximum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getActualMinimum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_actual_minimum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span class="modifier">static array <span class="methodname">IntlCalendar::getAvailableLocales ( <span class="methodparam">void )
array <span class="methodname">intlcal_get_available_locales ( <span class="methodparam">void )
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getDayOfWeekType ( <span
class="methodparam">int $dayOfWeek
)
int<span
class="type">false <span
class="methodname">intlcal_get_day_of_week_type ( <span
class="methodparam">IntlCalendar $cal
, int
$dayOfWeek
)
public int <span class="methodname">IntlCalendar::getErrorCode ( <span class="methodparam">void )
public string IntlCalendar::getErrorMessage ( <span class="methodparam">void )
public <span class="type">intfalse <span class="methodname">IntlCalendar::getFirstDayOfWeek ( <span class="methodparam">void )
int<span
class="type">false <span
class="methodname">intlcal_get_first_day_of_week ( <span
class="methodparam">IntlCalendar $cal
)
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getGreatestMinimum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_greatest_minimum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span
class="modifier">static <span
class="type">Iteratorfalse <span
class="methodname">IntlCalendar::getKeywordValuesForLocale (
string $key
, string
$locale
, <span
class="type">bool $commonlyUsed
)
static <span
class="type">Iteratorfalse <span
class="methodname">intlcal_get_keyword_values_for_locale (
string $key
, string
$locale
, <span
class="type">bool $commonlyUsed
)
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getLeastMaximum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_least_maximum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span
class="type">stringfalse <span
class="methodname">IntlCalendar::getLocale ( <span
class="methodparam">int $localeType
)
string<span
class="type">false <span
class="methodname">intlcal_get_locale ( <span
class="methodparam">IntlCalendar $cal
, int
$localeType
)
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getMaximum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_maximum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span class="type">intfalse <span class="methodname">IntlCalendar::getMinimalDaysInFirstWeek ( void )
int<span
class="type">false <span
class="methodname">intlcal_get_minimal_days_in_first_week (
IntlCalendar
$cal
)
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getMinimum ( <span
class="methodparam">int $field
)
int<span
class="type">false <span
class="methodname">intlcal_get_minimum ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public <span class="modifier">static float <span class="methodname">IntlCalendar::getNow ( <span class="methodparam">void )
float <span class="methodname">intlcal_get_now ( <span class="methodparam">void )
public int <span class="methodname">IntlCalendar::getRepeatedWallTimeOption ( void )
int <span
class="methodname">intlcal_get_repeated_wall_time_option (
IntlCalendar
$cal
)
public int <span class="methodname">IntlCalendar::getSkippedWallTimeOption ( <span class="methodparam">void )
int <span
class="methodname">intlcal_get_skipped_wall_time_option (
IntlCalendar
$cal
)
public float IntlCalendar::getTime ( <span class="methodparam">void )
float <span
class="methodname">intlcal_get_time ( <span
class="methodparam">IntlCalendar $cal
)
public <span class="type">IntlTimeZone <span class="methodname">IntlCalendar::getTimeZone ( <span class="methodparam">void )
IntlTimeZone <span
class="methodname">intlcal_get_time_zone ( <span
class="methodparam">IntlCalendar $cal
)
public string IntlCalendar::getType ( <span class="methodparam">void )
string <span
class="methodname">intlcal_get_type ( <span
class="methodparam">IntlCalendar $cal
)
public <span
class="type">intfalse <span
class="methodname">IntlCalendar::getWeekendTransition ( <span
class="methodparam">string $dayOfWeek
)
int<span
class="type">false <span
class="methodname">intlcal_get_weekend_transition ( <span
class="methodparam">IntlCalendar $cal
, string
$dayOfWeek
)
public bool IntlCalendar::inDaylightTime ( <span class="methodparam">void )
bool <span
class="methodname">intlcal_in_daylight_time ( <span
class="methodparam">IntlCalendar $cal
)
public bool
IntlCalendar::isEquivalentTo ( <span
class="methodparam">IntlCalendar
$other
)
bool <span
class="methodname">intlcal_is_equivalent_to ( <span
class="methodparam">IntlCalendar $cal
, IntlCalendar
$other
)
public bool IntlCalendar::isLenient ( <span class="methodparam">void )
bool <span
class="methodname">intlcal_is_lenient ( <span
class="methodparam">IntlCalendar $cal
)
public bool
IntlCalendar::isSet ( <span
class="methodparam">int $field
)
bool <span
class="methodname">intlcal_is_set ( <span
class="methodparam">IntlCalendar $cal
, int
$field
)
public bool
IntlCalendar::isWeekend ([ <span
class="methodparam">float $date
<span
class="initializer"> = NULL ] )
bool <span
class="methodname">intlcal_is_weekend ( <span
class="methodparam">IntlCalendar $cal
[, float
$date
= NULL ] )
public bool
IntlCalendar::roll ( <span
class="methodparam">int $field
,
mixed
$amountOrUpOrDown
)
bool <span
class="methodname">intlcal_roll ( <span
class="methodparam">IntlCalendar $cal
, int
$field
, <span
class="type">mixed $amountOrUpOrDown
)
public bool
IntlCalendar::set ( <span
class="methodparam">int $field
,
int $value
)
public bool
IntlCalendar::set ( <span
class="methodparam">int $year
, <span
class="methodparam">int $month
[,
int
$dayOfMonth
= NULL [, <span
class="methodparam">int $hour
<span
class="initializer"> = NULL [, <span
class="methodparam">int $minute
<span
class="initializer"> = NULL [, <span
class="methodparam">int $second
<span
class="initializer"> = NULL ]]]] )
bool <span
class="methodname">intlcal_set ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $field
,
int $value
)
bool <span
class="methodname">intlcal_set ( <span
class="type">IntlCalendar $cal
, <span
class="methodparam">int $year
, <span
class="methodparam">int $month
[,
int
$dayOfMonth
= NULL [, <span
class="methodparam">int $hour
<span
class="initializer"> = NULL [, <span
class="methodparam">int $minute
<span
class="initializer"> = NULL [, <span
class="methodparam">int $second
<span
class="initializer"> = NULL ]]]] )
public bool
IntlCalendar::setFirstDayOfWeek ( <span
class="methodparam">int $dayOfWeek
)
bool <span
class="methodname">intlcal_set_first_day_of_week ( <span
class="methodparam">IntlCalendar $cal
, int
$dayOfWeek
)
public bool
IntlCalendar::setLenient ( <span
class="methodparam">bool $isLenient
)
bool <span
class="methodname">intlcal_set_lenient ( <span
class="methodparam">IntlCalendar $cal
, bool
$isLenient
)
public bool
IntlCalendar::setMinimalDaysInFirstWeek
( int
$minimalDays
)
bool <span
class="methodname">intlcal_set_minimal_days_in_first_week (
IntlCalendar
$cal
, int
$minimalDays
)
public bool
IntlCalendar::setRepeatedWallTimeOption
( int
$wallTimeOption
)
bool <span
class="methodname">intlcal_set_repeated_wall_time_option (
IntlCalendar
$cal
, int
$wallTimeOption
)
public bool
IntlCalendar::setSkippedWallTimeOption (
int
$wallTimeOption
)
bool <span
class="methodname">intlcal_set_skipped_wall_time_option (
IntlCalendar
$cal
, int
$wallTimeOption
)
public bool
IntlCalendar::setTime ( <span
class="methodparam">float $date
)
bool <span
class="methodname">intlcal_set_time ( <span
class="methodparam">IntlCalendar $cal
, float
$date
)
public bool
IntlCalendar::setTimeZone ( <span
class="methodparam">mixed $timeZone
)
bool <span
class="methodname">intlcal_set_time_zone ( <span
class="methodparam">IntlCalendar $cal
, mixed
$timeZone
)
public DateTime IntlCalendar::toDateTime ( <span class="methodparam">void )
DateTime <span
class="methodname">intlcal_to_date_time ( <span
class="methodparam">IntlCalendar $cal
)
}
IntlGregorianCalendar::__construct
Create the Gregorian Calendar class
说明
public <span
class="methodname">IntlGregorianCalendar::__construct ([ <span
class="methodparam">IntlTimeZone $tz
[, string
$locale
]] )
public <span
class="methodname">IntlGregorianCalendar::__construct ( <span
class="methodparam">int
$timeZoneOrYear
, <span
class="type">int $localeOrMonth
, <span
class="methodparam">int $dayOfMonth
)
public <span
class="methodname">IntlGregorianCalendar::__construct ( <span
class="methodparam">int
$timeZoneOrYear
, <span
class="type">int $localeOrMonth
, <span
class="methodparam">int $dayOfMonth
,
int $hour
,
int $minute
[, int
$second
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
tz
locale
timeZoneOrYear
localeOrMonth
dayOfMonth
hour
minute
second
IntlGregorianCalendar::getGregorianChange
Get the Gregorian Calendar change date
说明
public <span class="type">floatfalse <span class="methodname">IntlGregorianCalendar::getGregorianChange ( void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
Returns the change date 或者在失败时返回 false
.
IntlGregorianCalendar::isLeapYear
Determine if the given year is a leap year
说明
public bool
IntlGregorianCalendar::isLeapYear (
int $year
)
Warning
本函数还未编写文档,仅有参数列表。
参数
year
返回值
Returns true
for leap years, false
otherwise and on failure.
IntlGregorianCalendar::setGregorianChange
Set the Gregorian Calendar the change date
说明
public bool
<span
class="methodname">IntlGregorianCalendar::setGregorianChange (
float $date
)
Warning
本函数还未编写文档,仅有参数列表。
参数
date
返回值
成功时返回 true
, 或者在失败时返回 false
。
简介
类摘要
IntlTimeZone
class IntlTimeZone {
/* Constants */
const int
IntlTimeZone::DISPLAY_SHORT
= 1 ;
const int
IntlTimeZone::DISPLAY_LONG
= 2 ;
/* 方法 */
public <span
class="modifier">static int <span
class="methodname">countEquivalentIDs ( <span
class="methodparam">string $zoneId
)
public <span class="modifier">static IntlTimeZone createDefault ( <span class="methodparam">void )
public <span
class="modifier">static IntlIterator
createEnumeration ([ <span
class="methodparam">mixed
$countryOrRawOffset
] )
public <span
class="modifier">static IntlTimeZone
createTimeZone ( <span
class="methodparam">string $zoneId
)
public <span
class="modifier">static <span
class="type">IntlIteratorfalse
createTimeZoneIDEnumeration ( <span
class="methodparam">int $zoneType
[,
string
$region
[, <span
class="type">int $rawOffset
]] )
public <span
class="modifier">static IntlTimeZone
fromDateTimeZone ( <span
class="methodparam">DateTimeZone
$zoneId
)
public <span
class="modifier">static string <span
class="methodname">getCanonicalID ( <span
class="methodparam">string $zoneId
[, bool
&$isSystemID
] )
public string
getDisplayName ([ <span
class="methodparam">bool $isDaylight
[, int
$style
[, <span
class="type">string $locale
]]] )
public int <span class="methodname">getDSTSavings ( <span class="methodparam">void )
public <span
class="modifier">static string <span
class="methodname">getEquivalentID ( <span
class="methodparam">string $zoneId
,
int $index
)
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
public <span class="modifier">static IntlTimeZone getGMT ( <span class="methodparam">void )
public string getID ( <span class="methodparam">void )
public <span
class="modifier">static <span
class="type">stringfalse <span
class="methodname">getIDForWindowsID ( <span
class="methodparam">string $timezone
[, string
$region
] )
public bool
getOffset ( <span
class="methodparam">float $date
,
bool $local
, int
&$rawOffset
, <span
class="type">int &$dstOffset
)
public int <span class="methodname">getRawOffset ( <span class="methodparam">void )
public <span
class="modifier">static <span
class="type">stringfalse <span
class="methodname">getRegion ( <span
class="type">string $zoneId
)
public <span class="modifier">static string <span class="methodname">getTZDataVersion ( <span class="methodparam">void )
public <span class="modifier">static IntlTimeZone getUnknown ( <span class="methodparam">void )
public <span
class="modifier">static <span
class="type">stringfalse <span
class="methodname">getWindowsID ( <span
class="type">string $timezone
)
public bool
hasSameRules ( <span
class="methodparam">IntlTimeZone
$otherTimeZone
)
public <span class="type">DateTimeZone <span class="methodname">toDateTimeZone ( <span class="methodparam">void )
public bool useDaylightTime ( <span class="methodparam">void )
}
预定义常量
IntlTimeZone::DISPLAY_SHORT
IntlTimeZone::DISPLAY_LONG
IntlTimeZone::countEquivalentIDs
intltz_count_equivalent_ids
Get the number of IDs in the equivalency group that includes the given ID
说明
面向对象风格 (method):
public <span
class="modifier">static int <span
class="methodname">IntlTimeZone::countEquivalentIDs ( <span
class="methodparam">string $zoneId
)
过程化风格:
int <span
class="methodname">intltz_count_equivalent_ids ( <span
class="methodparam">string $zoneId
)
Warning
本函数还未编写文档,仅有参数列表。
参数
zoneId
返回值
IntlTimeZone::createDefault
intltz_create_default
Create a new copy of the default timezone for this host
说明
面向对象风格 (method):
public <span class="modifier">static IntlTimeZone IntlTimeZone::createDefault ( <span class="methodparam">void )
过程化风格:
IntlTimeZone <span class="methodname">intltz_create_default ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlTimeZone::createEnumeration
intltz_create_enumeration
Get an enumeration over time zone IDs associated with the given country or offset
说明
面向对象风格 (method):
public <span
class="modifier">static IntlIterator
IntlTimeZone::createEnumeration ([
mixed
$countryOrRawOffset
] )
过程化风格:
IntlIterator <span
class="methodname">intltz_create_enumeration ([ <span
class="methodparam">mixed
$countryOrRawOffset
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
countryOrRawOffset
返回值
IntlTimeZone::createTimeZone
intltz_create_time_zone
Create a timezone object for the given ID
说明
面向对象风格 (method):
public <span
class="modifier">static IntlTimeZone
IntlTimeZone::createTimeZone ( <span
class="methodparam">string $zoneId
)
过程化风格:
IntlTimeZone <span
class="methodname">intltz_create_time_zone ( <span
class="methodparam">string $zoneId
)
Warning
本函数还未编写文档,仅有参数列表。
参数
zoneId
返回值
IntlTimeZone::createTimeZoneIDEnumeration
intltz_create_time_zone_id_enumeration
Get an enumeration over system time zone IDs with the given filter conditions
说明
面向对象风格 (method):
public <span
class="modifier">static <span
class="type">IntlIteratorfalse
<span
class="methodname">IntlTimeZone::createTimeZoneIDEnumeration (
int
$zoneType
[, <span
class="type">string $region
[, <span
class="methodparam">int $rawOffset
]] )
过程化风格:
IntlIterator<span
class="type">false <span
class="methodname">intltz_create_time_zone_id_enumeration (
int
$zoneType
[, <span
class="type">string $region
[, <span
class="methodparam">int $rawOffset
]] )
Warning
本函数还未编写文档,仅有参数列表。
参数
zoneType
region
rawOffset
返回值
Returns IntlIterator 或者在失败时返回
false
.
IntlTimeZone::fromDateTimeZone
intltz_from_date_time_zone
Create a timezone object from DateTimeZone
说明
面向对象风格 (method):
public <span
class="modifier">static IntlTimeZone
IntlTimeZone::fromDateTimeZone ( <span
class="methodparam">DateTimeZone
$zoneId
)
过程化风格:
IntlTimeZone <span
class="methodname">intltz_from_date_time_zone ( <span
class="methodparam">DateTimeZone
$zoneId
)
Warning
本函数还未编写文档,仅有参数列表。
参数
zoneId
返回值
IntlTimeZone::getCanonicalID
intltz_get_canonical_id
Get the canonical system timezone ID or the normalized custom time zone ID for the given time zone ID
说明
面向对象风格 (method):
public <span
class="modifier">static string <span
class="methodname">IntlTimeZone::getCanonicalID ( <span
class="methodparam">string $zoneId
[, bool
&$isSystemID
] )
过程化风格:
string <span
class="methodname">intltz_get_canonical_id ( <span
class="methodparam">string $zoneId
[, bool
&$isSystemID
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
zoneId
isSystemID
返回值
IntlTimeZone::getDisplayName
intltz_get_display_name
Get a name of this time zone suitable for presentation to the user
说明
面向对象风格 (method):
public string
IntlTimeZone::getDisplayName ([ <span
class="methodparam">bool $isDaylight
[, int
$style
[, <span
class="type">string $locale
]]] )
过程化风格:
string <span
class="methodname">intltz_get_display_name ( <span
class="methodparam">IntlTimeZone
$timezone
[, <span
class="type">bool $isDaylight
[, <span
class="methodparam">int $style
[,
string
$locale
]]] )
Warning
本函数还未编写文档,仅有参数列表。
参数
isDaylight
style
locale
返回值
IntlTimeZone::getDSTSavings
intltz_get_dst_savings
Get the amount of time to be added to local standard time to get local wall clock time
说明
面向对象风格 (method):
public int <span class="methodname">IntlTimeZone::getDSTSavings ( <span class="methodparam">void )
过程化风格:
int <span
class="methodname">intltz_get_dst_savings ( <span
class="methodparam">IntlTimeZone
$timezone
)
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlTimeZone::getEquivalentID
intltz_get_equivalent_id
Get an ID in the equivalency group that includes the given ID
说明
面向对象风格 (method):
public <span
class="modifier">static string <span
class="methodname">IntlTimeZone::getEquivalentID ( <span
class="methodparam">string $zoneId
,
int $index
)
过程化风格:
string <span
class="methodname">intltz_get_equivalent_id ( <span
class="methodparam">string $zoneId
,
int $index
)
Warning
本函数还未编写文档,仅有参数列表。
参数
zoneId
index
返回值
IntlTimeZone::getErrorCode
intltz_get_error_code
Get last error code on the object
说明
面向对象风格 (method):
public int <span class="methodname">IntlTimeZone::getErrorCode ( <span class="methodparam">void )
过程化风格:
int <span
class="methodname">intltz_get_error_code ( <span
class="methodparam">IntlTimeZone
$timezone
)
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlTimeZone::getErrorMessage
intltz_get_error_message
Get last error message on the object
说明
面向对象风格 (method):
public string IntlTimeZone::getErrorMessage ( <span class="methodparam">void )
过程化风格:
string <span
class="methodname">intltz_get_error_message ( <span
class="methodparam">IntlTimeZone
$timezone
)
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlTimeZone::getGMT
intltz_get_gmt
Create GMT (UTC) timezone
说明
面向对象风格 (method):
public <span class="modifier">static IntlTimeZone IntlTimeZone::getGMT ( <span class="methodparam">void )
过程化风格:
IntlTimeZone <span class="methodname">intltz_get_gmt ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlTimeZone::getID
intltz_get_id
Get timezone ID
说明
面向对象风格 (method):
public string IntlTimeZone::getID ( <span class="methodparam">void )
过程化风格:
string <span
class="methodname">intltz_get_id ( <span
class="methodparam">IntlTimeZone
$timezone
)
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlTimeZone::getIDForWindowsID
intltz_get_id_for_windows_id
Translate a Windows timezone into a system timezone
说明
面向对象风格 (method):
public <span
class="modifier">static <span
class="type">stringfalse <span
class="methodname">IntlTimeZone::getIDForWindowsID ( <span
class="methodparam">string $timezone
[, string
$region
] )
过程化风格:
string<span
class="type">false <span
class="methodname">intltz_get_id_for_windows_id ( <span
class="methodparam">string $timezone
[, string
$region
] )
Translates a Windows timezone (e.g. "Pacific Standard Time") into a system timezone (e.g. "America/Los_Angeles").
Note: This function requires ICU version ≥ 52.
Warning
本函数还未编写文档,仅有参数列表。
参数
timezone
region
返回值
Returns the system timezone 或者在失败时返回 false
.
参见
- IntlTimeZone::getWindowsID
IntlTimeZone::getOffset
intltz_get_offset
Get the time zone raw and GMT offset for the given moment in time
说明
面向对象风格 (method):
public bool
IntlTimeZone::getOffset ( <span
class="methodparam">float $date
,
bool $local
, int
&$rawOffset
, <span
class="type">int &$dstOffset
)
过程化风格:
bool <span
class="methodname">intltz_get_offset ( <span
class="methodparam">IntlTimeZone
$timezone
, <span
class="type">float $date
, <span
class="methodparam">bool $local
,
int
&$rawOffset
, <span
class="type">int &$dstOffset
)
Warning
本函数还未编写文档,仅有参数列表。
参数
date
local
rawOffset
dstOffset
返回值
IntlTimeZone::getRawOffset
intltz_get_raw_offset
Get the raw GMT offset (before taking daylight savings time into account
说明
面向对象风格 (method):
public int <span class="methodname">IntlTimeZone::getRawOffset ( <span class="methodparam">void )
过程化风格:
int <span
class="methodname">intltz_get_raw_offset ( <span
class="methodparam">IntlTimeZone
$timezone
)
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlTimeZone::getRegion
intltz_get_region
Get the region code associated with the given system time zone ID
说明
面向对象风格 (method):
public <span
class="modifier">static <span
class="type">stringfalse <span
class="methodname">IntlTimeZone::getRegion ( <span
class="methodparam">string $zoneId
)
过程化风格:
string<span
class="type">false <span
class="methodname">intltz_get_region ( <span
class="methodparam">string $zoneId
)
Warning
本函数还未编写文档,仅有参数列表。
参数
zoneId
返回值
Return region 或者在失败时返回 false
.
IntlTimeZone::getTZDataVersion
intltz_get_tz_data_version
Get the timezone data version currently used by ICU
说明
面向对象风格 (method):
public <span class="modifier">static string <span class="methodname">IntlTimeZone::getTZDataVersion ( <span class="methodparam">void )
过程化风格:
string <span class="methodname">intltz_get_tz_data_version ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlTimeZone::getUnknown
intltz_get_unknown
Get the "unknown" time zone
说明
面向对象风格 (method):
public <span class="modifier">static IntlTimeZone IntlTimeZone::getUnknown ( <span class="methodparam">void )
过程化风格:
IntlTimeZone <span class="methodname">intltz_get_unknown ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
Returns IntlTimeZone or null
on
failure.
IntlTimeZone::getWindowsID
intltz_get_windows_id
Translate a system timezone into a Windows timezone
说明
面向对象风格 (method):
public <span
class="modifier">static <span
class="type">stringfalse <span
class="methodname">IntlTimeZone::getWindowsID ( <span
class="methodparam">string $timezone
)
过程化风格:
string<span
class="type">false <span
class="methodname">intltz_get_windows_id ( <span
class="methodparam">string $timezone
)
Translates a system timezone (e.g. "America/Los_Angeles") into a Windows timezone (e.g. "Pacific Standard Time").
Note: This function requires ICU version ≥ 52.
Warning
本函数还未编写文档,仅有参数列表。
参数
timezone
返回值
Returns the Windows timezone 或者在失败时返回 false
.
参见
- IntlTimeZone::getIDForWindowsID
IntlTimeZone::hasSameRules
intltz_has_same_rules
Check if this zone has the same rules and offset as another zone
说明
面向对象风格 (method):
public bool
IntlTimeZone::hasSameRules ( <span
class="methodparam">IntlTimeZone
$otherTimeZone
)
过程化风格:
bool <span
class="methodname">intltz_has_same_rules ( <span
class="methodparam">IntlTimeZone
$timezone
, <span
class="type">IntlTimeZone $otherTimeZone
)
Warning
本函数还未编写文档,仅有参数列表。
参数
otherTimeZone
返回值
IntlTimeZone::toDateTimeZone
intltz_to_date_time_zone
Convert to DateTimeZone object
说明
面向对象风格 (method):
public <span class="type">DateTimeZone <span class="methodname">IntlTimeZone::toDateTimeZone ( <span class="methodparam">void )
过程化风格:
DateTimeZone <span
class="methodname">intltz_to_date_time_zone ( <span
class="methodparam">IntlTimeZone
$timezone
)
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlTimeZone::useDaylightTime
intltz_use_daylight_time
Check if this time zone uses daylight savings time
说明
面向对象风格 (method):
public bool IntlTimeZone::useDaylightTime ( <span class="methodparam">void )
过程化风格:
bool <span
class="methodname">intltz_use_daylight_time ( <span
class="methodparam">IntlTimeZone
$timezone
)
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
简介
Date Formatter is a concrete class that enables locale-dependent formatting/parsing of dates using pattern strings and/or canned patterns.
This class represents the ICU date formatting functionality. It allows users to display dates in a localized format or to parse strings into PHP date values using pattern strings and/or canned patterns.
Class synopsis
IntlDateFormatter
class IntlDateFormatter {
/* 方法 */
public <span
class="methodname">__construct ( <span
class="methodparam">string $locale
,
int
$datetype
, <span
class="type">int $timetype
[, <span
class="methodparam">mixed $timezone
<span
class="initializer"> = NULL [, <span
class="methodparam">mixed $calendar
<span
class="initializer"> = NULL [, <span
class="methodparam">string $pattern
<span
class="initializer"> = "" ]]] )
public <span
class="modifier">static <span
class="type">IntlDateFormatter <span
class="methodname">create ( <span
class="type">string $locale
, <span
class="methodparam">int $datetype
,
int
$timetype
[, <span
class="type">mixed $timezone
=
NULL [, <span
class="type">mixed $calendar
=
NULL [, <span
class="type">string $pattern
=
"" ]]] )
public string
format ( <span
class="type">mixed $value
)
public <span
class="modifier">static <span
class="type">stringfalse <span
class="methodname">formatObject ( <span
class="type">object $object
[, <span
class="methodparam">mixed $format
<span
class="initializer"> = NULL [, <span
class="methodparam">string $locale
<span
class="initializer"> = NULL ]] )
public int <span class="methodname">getCalendar ( <span class="methodparam">void )
public int <span class="methodname">getDateType ( <span class="methodparam">void )
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
public string
getLocale ([ <span
class="methodparam">int $which
] )
public string getPattern ( <span class="methodparam">void )
public int <span class="methodname">getTimeType ( <span class="methodparam">void )
public string getTimeZoneId ( <span class="methodparam">void )
public <span class="type">IntlCalendar <span class="methodname">getCalendarObject ( <span class="methodparam">void )
public <span class="type">IntlTimeZonefalse getTimeZone ( <span class="methodparam">void )
public bool isLenient ( <span class="methodparam">void )
public array
localtime ( <span
class="methodparam">string $value
[,
int
&$position
] )
public int <span
class="methodname">parse ( <span
class="type">string $value
[, <span
class="methodparam">int &$position
]
)
public bool
setCalendar ( <span
class="methodparam">mixed $which
)
public bool
setLenient ( <span
class="methodparam">bool $lenient
)
public bool
setPattern ( <span
class="methodparam">string $pattern
)
public bool
setTimeZoneId ( <span
class="methodparam">string $zone
)
public bool
setTimeZone ( <span
class="methodparam">mixed $zone
)
}
参见
预定义常量
These constants are used to specify different formats in the constructor for DateType and TimeType.
IntlDateFormatter::NONE
(int)
Do not include this element
IntlDateFormatter::FULL
(int)
Completely specified style (Tuesday, April 12,
1952 AD or 3:30:42pm PST)
IntlDateFormatter::LONG
(int)
Long style (January 12, 1952 or 3:30:32pm)
IntlDateFormatter::MEDIUM
(int)
Medium style (Jan 12, 1952)
IntlDateFormatter::SHORT
(int)
Most abbreviated style, only essential data
(12/13/52 or 3:30pm)
IntlDateFormatter::RELATIVE_FULL
(int)
The same as IntlDateFormatter::FULL
, but
yesterday, today, and tomorrow show as yesterday, today, and
tomorrow, respectively. Available as of PHP 8.0.0, for dateType
only.
IntlDateFormatter::RELATIVE_LONG
(int)
The same as IntlDateFormatter::LONG
, but
yesterday, today, and tomorrow show as yesterday, today, and
tomorrow, respectively. Available as of PHP 8.0.0, for dateType
only.
IntlDateFormatter::RELATIVE_MEDIUM
(int)
The same as IntlDateFormatter::MEDIUM
, but
yesterday, today, and tomorrow show as yesterday, today, and
tomorrow, respectively. Available as of PHP 8.0.0, for dateType
only.
IntlDateFormatter::RELATIVE_SHORT
(int)
The same as IntlDateFormatter::SHORT
, but
yesterday, today, and tomorrow show as yesterday, today, and
tomorrow, respectively. Available as of PHP 8.0.0, for dateType
only.
The following int constants are used to specify the calendar. These calendars are all based directly on the Gregorian calendar. Non-Gregorian calendars need to be specified in locale. Examples might include locale="hi@calendar=BUDDHIST".
IntlDateFormatter::TRADITIONAL
(int)
Non-Gregorian Calendar
IntlDateFormatter::GREGORIAN
(int)
Gregorian Calendar
IntlDateFormatter::create
datefmt_create
IntlDateFormatter::__construct
Create a date formatter
说明
面向对象风格
public <span
class="modifier">static <span
class="type">IntlDateFormatter <span
class="methodname">IntlDateFormatter::create ( <span
class="methodparam">string $locale
,
int
$datetype
, <span
class="type">int $timetype
[, <span
class="methodparam">mixed $timezone
<span
class="initializer"> = NULL [, <span
class="methodparam">mixed $calendar
<span
class="initializer"> = NULL [, <span
class="methodparam">string $pattern
<span
class="initializer"> = "" ]]] )
面向对象风格 (constructor)
public <span
class="methodname">IntlDateFormatter::__construct ( <span
class="methodparam">string $locale
,
int
$datetype
, <span
class="type">int $timetype
[, <span
class="methodparam">mixed $timezone
<span
class="initializer"> = NULL [, <span
class="methodparam">mixed $calendar
<span
class="initializer"> = NULL [, <span
class="methodparam">string $pattern
<span
class="initializer"> = "" ]]] )
过程化风格
IntlDateFormatter <span
class="methodname">datefmt_create ( <span
class="methodparam">string $locale
,
int
$datetype
, <span
class="type">int $timetype
[, <span
class="methodparam">mixed $timezone
<span
class="initializer"> = NULL [, <span
class="methodparam">mixed $calendar
<span
class="initializer"> = NULL [, <span
class="methodparam">string $pattern
<span
class="initializer"> = "" ]]] )
Create a date formatter.
参数
locale
Locale to use when formatting or parsing or null
to use the value
specified in the ini setting
intl.default_locale.
datetype
Date type to use (none
, short
, medium
, long
,
full
). This is one of the
IntlDateFormatter constants.
It can also be null
, in which case ICUʼs default date type will be
used.
timetype
Time type to use (none
, short
, medium
, long
,
full
). This is one of the
IntlDateFormatter constants.
It can also be null
, in which case ICUʼs default time type will be
used.
timezone
Time zone ID. The default (and the one used if null
is given) is
the one returned by <span
class="function">date_default_timezone_get or, if applicable,
that of the IntlCalendar object passed
for the calendar
parameter. This ID must be a valid identifier on
ICUʼs database or an ID representing an explicit offset, such as
GMT-05:30.
This can also be an IntlTimeZone or a DateTimeZone object.
calendar
Calendar to use for formatting or parsing. The default value is
null
, which corresponds to IntlDateFormatter::GREGORIAN
.
This can either be one of the
IntlDateFormatter calendar constants
or an IntlCalendar. Any <span
class="classname">IntlCalendar object passed will be clone; it
will not be changed by the <span
class="classname">IntlDateFormatter. This will determine the
calendar type used (gregorian, islamic, persian, etc.) and, if
null
is given for the timezone
parameter, also the timezone
used.
pattern
Optional pattern to use when formatting or parsing. Possible patterns
are documented at
» http://userguide.icu-project.org/formatparse/datetime.
返回值
The created IntlDateFormatter or
false
in case of failure.
更新日志
版本 | 说明 |
---|---|
5.5.0/PECL 3.0.0 | An IntlCalendar object is allowed for Objects of type IntlTimeZone and DateTimeZone are allowed for Invalid timezone identifiers (including empty strings) are no longer allowed for If |
范例
示例 #1 datefmt_create example
<?php
$fmt = datefmt_create( "en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
'America/Los_Angeles', IntlDateFormatter::GREGORIAN );
echo "First Formatted output is ".datefmt_format( $fmt , 0);
$fmt = datefmt_create( "de-DE" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
'America/Los_Angeles',IntlDateFormatter::GREGORIAN );
echo "Second Formatted output is ".datefmt_format( $fmt , 0);
$fmt = datefmt_create( "en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
'America/Los_Angeles',IntlDateFormatter::GREGORIAN ,"MM/dd/yyyy");
echo "First Formatted output with pattern is ".datefmt_format( $fmt , 0);
$fmt = datefmt_create( "de-DE" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
'America/Los_Angeles',IntlDateFormatter::GREGORIAN ,"MM/dd/yyyy");
echo "Second Formatted output with pattern is ".datefmt_format( $fmt , 0);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter( "en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
'America/Los_Angeles',IntlDateFormatter::GREGORIAN );
echo "First Formatted output is ".$fmt->format(0);
$fmt = new IntlDateFormatter( "de-DE" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
'America/Los_Angeles',IntlDateFormatter::GREGORIAN );
echo "Second Formatted output is ".$fmt->format(0);
$fmt = new IntlDateFormatter( "en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
'America/Los_Angeles',IntlDateFormatter::GREGORIAN ,"MM/dd/yyyy");
echo "First Formatted output with pattern is ".$fmt->format(0);
$fmt = new IntlDateFormatter( "de-DE" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
'America/Los_Angeles',IntlDateFormatter::GREGORIAN , "MM/dd/yyyy");
echo "Second Formatted output with pattern is ".$fmt->format(0);
?>
以上例程会输出:
First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
Second Formatted output is Mittwoch, 31. Dezember 1969 16:00 Uhr GMT-08:00
First Formatted output with pattern is 12/31/1969
Second Formatted output with pattern is 12/31/1969
参见
- datefmt_format
- datefmt_parse
- datefmt_get_error_code
- datefmt_get_error_message
IntlDateFormatter::format
datefmt_format
Format the date/time value as a string
说明
面向对象风格
public string
IntlDateFormatter::format ( <span
class="methodparam">mixed $value
)
过程化风格
string <span
class="methodname">datefmt_format ( <span
class="methodparam">IntlDateFormatter
$fmt
, <span
class="type">mixed $value
)
Formats the time value as a string.
参数
fmt
The date formatter resource.
value
Value to format. This may be a <span
class="classname">DateTimeInterface object, an <span
class="classname">IntlCalendar object, a <span
class="type">numeric type representing a (possibly fractional)
number of seconds since epoch or an array in
the format output by localtime.
If a DateTime or an <span class="classname">IntlCalendar object is passed, its timezone is not considered. The object will be formatted using the formaterʼs configured timezone. If one wants to use the timezone of the object to be formatted, <span class="function">IntlDateFormatter::setTimeZone must be called before with the objectʼs timezone. Alternatively, the static function IntlDateFormatter::formatObject may be used instead.
返回值
The formatted string or, if an error occurred, false
.
更新日志
版本 | 说明 |
---|---|
7.1.5 | Support for providing general DateTimeInterface objects to the value parameter was added. Formerly, only proper DateTime objects were supported. |
PECL 3.0.0 | Support for providing IntlCalendar objects to the value parameter was added. |
范例
示例 #1 datefmt_format example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'First Formatted output is ' . datefmt_format($fmt, 0);
$fmt = datefmt_create(
'de-DE',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'Second Formatted output is ' . datefmt_format($fmt, 0);
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo 'First Formatted output with pattern is ' . datefmt_format($fmt, 0);
$fmt = datefmt_create(
'de-DE',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo "Second Formatted output with pattern is " . datefmt_format($fmt, 0);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'First Formatted output is ' . $fmt->format(0);
$fmt = new IntlDateFormatter(
'de-DE',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'Second Formatted output is ' . $fmt->format(0);
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo 'First Formatted output with pattern is ' . $fmt->format(0);
$fmt = new IntlDateFormatter(
'de-DE',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo 'Second Formatted output with pattern is ' . $fmt->format(0);
?>
以上例程会输出:
First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
Second Formatted output is Mittwoch, 31. Dezember 1969 16:00 Uhr GMT-08:00
First Formatted output with pattern is 12/31/1969
Second Formatted output with pattern is 12/31/1969
示例 #3 With IntlCalendar object
<?php
$tz = reset(iterator_to_array(IntlTimeZone::createEnumeration('FR')));
$formatter = IntlDateFormatter::create(
'fr_FR',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
$tz,
IntlDateFormatter::GREGORIAN
);
$cal = IntlCalendar::createInstance($tz, '@calendar=islamic-civil');
$cal->set(IntlCalendar::FIELD_MONTH, 8); //9th month, Ramadan
$cal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 1); //1st day
$cal->clear(IntlCalendar::FIELD_HOUR_OF_DAY);
$cal->clear(IntlCalendar::FIELD_MINUTE);
$cal->clear(IntlCalendar::FIELD_SECOND);
$cal->clear(IntlCalendar::FIELD_MILLISECOND);
echo "In this islamic year, Ramadan started/will start on:\n\t",
$formatter->format($cal), "\n";
//Itʼs the formatterʼs timezone that is used:
$formatter->setTimeZone('Asia/Tokyo');
echo "After changing timezone:\n\t",
$formatter->format($cal), "\n";
以上例程会输出:
In this islamic year, Ramadan started/will start on:
mardi 9 juillet 2013 19:00:00 heure avancée d’Europe centrale
After changing timezone:
mercredi 10 juillet 2013 02:00:00 heure normale du Japon
参见
- datefmt_create
- datefmt_parse
- datefmt_get_error_code
- datefmt_get_error_message
- datefmt_format_object
IntlDateFormatter::formatObject
datefmt_format_object
Formats an object
说明
面向对象风格
public <span
class="modifier">static <span
class="type">stringfalse <span
class="methodname">IntlDateFormatter::formatObject ( <span
class="methodparam">object $object
[, mixed
$format
= NULL [, <span
class="methodparam">string $locale
<span
class="initializer"> = NULL ]] )
过程化风格
public <span
class="modifier">static <span
class="type">stringfalse <span
class="methodname">datefmt_format_object ( <span
class="methodparam">object $object
[, mixed
$format
= NULL [, <span
class="methodparam">string $locale
<span
class="initializer"> = NULL ]] )
This function allows formatting an <span class="classname">IntlCalendar or <span class="classname">DateTime object without first explicitly creating a IntlDateFormatter object.
The temporary IntlDateFormatter that will be created will take the timezone from the passed in object. The timezone database bundled with PHP will not be used – ICU's will be used instead. The timezone identifier used in <span class="classname">DateTime objects must therefore also exist in ICU's database.
参数
object
An object of type IntlCalendar or <span
class="classname">DateTime. The timezone information in the
object will be used.
format
How to format the date/time. This can either be an <span
class="type">array with two elements (first the date style, then
the time style, these being one of the constants
IntlDateFormatter::NONE
, IntlDateFormatter::SHORT
,
IntlDateFormatter::MEDIUM
, IntlDateFormatter::LONG
,
IntlDateFormatter::FULL
), an int with
the value of one of these constants (in which case it will be used both
for the time and the date) or a string with
the format described in
» the ICU documentation.
If null
, the default style will be used.
locale
The locale to use, or null
to use the
default one.
返回值
A string with result 或者在失败时返回 false
.
范例
示例 #1 IntlDateFormatter::formatObject examples
<?php
/* default timezone is irrelevant; timezone taken from the object */
ini_set('date.timezone', 'UTC');
/* default locale is taken from this ini setting */
ini_set('intl.default_locale', 'fr_FR');
$cal = IntlCalendar::fromDateTime("2013-06-06 17:05:06 Europe/Dublin");
echo "default:\n\t",
IntlDateFormatter::formatObject($cal),
"\n";
echo "long \$format (full):\n\t",
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL),
"\n";
echo "array \$format (none, full):\n\t",
IntlDateFormatter::formatObject($cal, array(
IntlDateFormatter::NONE,
IntlDateFormatter::FULL)),
"\n";
echo "string \$format (d 'of' MMMM y):\n\t",
IntlDateFormatter::formatObject($cal, "d 'of' MMMM y", 'en_US'),
"\n";
echo "with DateTime:\n\t",
IntlDateFormatter::formatObject(
new DateTime("2013-09-09 09:09:09 Europe/Madrid"),
IntlDateFormatter::FULL,
'es_ES'),
"\n";
以上例程会输出:
default:
6 juin 2013 17:05:06
long $format (full):
jeudi 6 juin 2013 17:05:06 heure d’été irlandaise
array $format (none, full):
17:05:06 heure d’été irlandaise
string $format (d 'of' MMMM y):
6 of June 2013
with DateTime:
lunes, 9 de septiembre de 2013 09:09:09 Hora de verano de Europa central
IntlDateFormatter::getCalendar
datefmt_get_calendar
Get the calendar type used for the IntlDateFormatter
说明
面向对象风格
public int <span class="methodname">IntlDateFormatter::getCalendar ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">datefmt_get_calendar ( <span
class="methodparam">IntlDateFormatter
$fmt
)
参数
fmt
The formatter resource
返回值
The
calendar type
being used by the formatter. Either IntlDateFormatter::TRADITIONAL
or IntlDateFormatter::GREGORIAN
.
范例
示例 #1 datefmt_get_calendar example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'calendar of the formatter is : ' . datefmt_get_calendar($fmt);
datefmt_set_calendar($fmt, IntlDateFormatter::TRADITIONAL);
echo 'Now calendar of the formatter is : ' . datefmt_get_calendar($fmt);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'calendar of the formatter is : ' . $fmt->getCalendar();
$fmt->setCalendar(IntlDateFormatter::TRADITIONAL);
echo 'Now calendar of the formatter is : ' . $fmt->getCalendar();
?>
以上例程会输出:
calendar of the formatter is : 1
Now calendar of the formatter is : 0
参见
- datefmt_get_calendar_object
- datefmt_set_calendar
- datefmt_create
IntlDateFormatter::getDateType
datefmt_get_datetype
Get the datetype used for the IntlDateFormatter
说明
面向对象风格
public int <span class="methodname">IntlDateFormatter::getDateType ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">datefmt_get_datetype ( <span
class="methodparam">IntlDateFormatter
$fmt
)
Returns date type used by the formatter.
参数
fmt
The formatter resource.
返回值
The current date type value of the formatter.
范例
示例 #1 datefmt_get_datetype example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'datetype of the formatter is : ' . datefmt_get_datetype($fmt);
echo 'First Formatted output with datetype is ' . datefmt_format($fmt, 0);
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::SHORT,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'Now datetype of the formatter is : ' . datefmt_get_datetype($fmt);
echo 'Second Formatted output with datetype is ' . datefmt_format($fmt, 0);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'datetype of the formatter is : ' . $fmt->getDateType();
echo 'First Formatted output is ' . $fmt->format(0);
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::SHORT,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'Now datetype of the formatter is : ' . $fmt->getDateType();
echo 'Second Formatted output is ' . $fmt->format(0);
?>
以上例程会输出:
datetype of the formatter is : 0
First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
Now datetype of the formatter is : 2
Second Formatted output is 12/31/69 4:00:00 PM PT
参见
- datefmt_get_timetype
- datefmt_create
IntlDateFormatter::getErrorCode
datefmt_get_error_code
Get the error code from last operation
说明
面向对象风格
public int <span class="methodname">IntlDateFormatter::getErrorCode ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">datefmt_get_error_code ( <span
class="methodparam">IntlDateFormatter
$fmt
)
Get the error code from last operation. Returns error code from the last number formatting operation.
参数
fmt
The formatter resource.
返回值
The error code, one of UErrorCode values. Initial value is U_ZERO_ERROR.
范例
示例 #1 datefmt_get_error_code example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
$str = datefmt_format($fmt);
if (!$str) {
printf(
"ERROR: %s (%d)\n",
datefmt_get_error_message($fmt),
datefmt_get_error_code($fmt)
);
}
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
$str = $fmt->format();
if (!$str) {
printf(
"ERROR: %s (%d)\n",
$fmt->getErrorMessage(),
$fmt->getErrorCode()
);
}
?>
以上例程会输出:
ERROR: U_ZERO_ERROR (0)
参见
- datefmt_get_error_message
- intl_get_error_code
- intl_is_failure
IntlDateFormatter::getErrorMessage
datefmt_get_error_message
Get the error text from the last operation
说明
面向对象风格
public string IntlDateFormatter::getErrorMessage ( void )
过程化风格
string <span
class="methodname">datefmt_get_error_message ( <span
class="methodparam">IntlDateFormatter
$fmt
)
Get the error text from the last operation.
参数
fmt
The formatter resource.
返回值
Description of the last error.
范例
示例 #1 datefmt_get_error_message example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
$str = datefmt_format($fmt);
if (!$str) {
printf(
"ERROR: %s (%d)\n",
datefmt_get_error_message($fmt),
datefmt_get_error_code($fmt)
);
}
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
$str = $fmt->format();
if(!$str) {
printf(
"ERROR: %s (%d)\n",
$fmt->getErrorMessage(),
$fmt->getErrorCode()
);
}
?>
以上例程会输出:
ERROR: U_ZERO_ERROR (0)
参见
- datefmt_get_error_code
- intl_get_error_code
- intl_is_failure
IntlDateFormatter::getLocale
datefmt_get_locale
Get the locale used by formatter
说明
面向对象风格
public string
IntlDateFormatter::getLocale ([ <span
class="methodparam">int $which
] )
过程化风格
string <span
class="methodname">datefmt_get_locale ( <span
class="methodparam">IntlDateFormatter
$fmt
[, <span
class="type">int $which
] )
Get locale used by the formatter.
参数
fmt
The formatter resource
hich
You can choose between valid and actual locale (
Locale::VALID_LOCALE
, Locale::ACTUAL_LOCALE
, respectively).
The default is the actual locale.
返回值
the locale of this formatter or 'false' if error
范例
示例 #1 datefmt_get_locale example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'locale of the formatter is : " . datefmt_get_locale($fmt);
echo 'First Formatted output is " . datefmt_format($fmt, 0);
$fmt = datefmt_create(
'de-DE',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'locale of the formatter is : ' . datefmt_get_locale($fmt);
echo 'Second Formatted output is ' . datefmt_format($fmt, 0);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'locale of the formatter is : ' . $fmt->getLocale();
echo 'First Formatted output is ' . $fmt->format(0);
$fmt = new IntlDateFormatter(
'de-DE',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'locale of the formatter is : ' . $fmt->getLocale();
echo 'Second Formatted output is ' . $fmt->format(0);
?>
以上例程会输出:
locale of the formatter is : en
First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
locale of the formatter is : de
Second Formatted output is Mittwoch, 31. Dezember 1969 16:00 Uhr GMT-08:00
参见
- datefmt_create
IntlDateFormatter::getPattern
datefmt_get_pattern
Get the pattern used for the IntlDateFormatter
说明
面向对象风格
public string IntlDateFormatter::getPattern ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">datefmt_get_pattern ( <span
class="methodparam">IntlDateFormatter
$fmt
)
Get pattern used by the formatter.
参数
fmt
The formatter resource.
返回值
The pattern string being used to format/parse.
范例
示例 #1 datefmt_get_pattern example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo 'pattern of the formatter is : ' . datefmt_get_pattern($fmt);
echo 'First Formatted output with pattern is ' . datefmt_format($fmt, 0);
datefmt_set_pattern($fmt,'yyyymmdd hh:mm:ss z');
echo 'Now pattern of the formatter is : ' . datefmt_get_pattern($fmt);
echo 'Second Formatted output with pattern is ' . datefmt_format($fmt, 0);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo 'pattern of the formatter is : ' . $fmt->getPattern();
echo 'First Formatted output is ' . $fmt->format(0);
$fmt->setPattern('yyyymmdd hh:mm:ss z');
echo 'Now pattern of the formatter is : ' . $fmt->getPattern();
echo 'Second Formatted output is ' . $fmt->format(0);
?>
以上例程会输出:
pattern of the formatter is : MM/dd/yyyy
First Formatted output is 12/31/1969
Now pattern of the formatter is : yyyymmdd hh:mm:ss z
Second Formatted output is 19690031 04:00:00 PST
参见
- datefmt_set_pattern
- datefmt_create
IntlDateFormatter::getTimeType
datefmt_get_timetype
Get the timetype used for the IntlDateFormatter
说明
面向对象风格
public int <span class="methodname">IntlDateFormatter::getTimeType ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">datefmt_get_timetype ( <span
class="methodparam">IntlDateFormatter
$fmt
)
Return time type used by the formatter.
参数
fmt
The formatter resource.
返回值
The current date type value of the formatter.
范例
示例 #1 datefmt_get_timetype example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'timetype of the formatter is : ' . datefmt_get_timetype($fmt);
echo 'First Formatted output with timetype is ' . datefmt_format($fmt, 0);
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::SHORT,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'Now timetype of the formatter is : ' . datefmt_get_timetype($fmt);
echo 'Second Formatted output with timetype is ' . datefmt_format($fmt, 0);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'timetype of the formatter is : ' . $fmt->getTimeType();
echo 'First Formatted output is ' . $fmt->format(0);
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::SHORT,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'Now timetype of the formatter is : ' . $fmt->getTimeType();
echo 'Second Formatted output is ' . $fmt->format(0);
?>
以上例程会输出:
timetype of the formatter is : 0
First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
Now timetype of the formatter is : 3
Second Formatted output is Wednesday, December 31, 1969 4:00 PM
参见
- datefmt_get_datetype
- datefmt_create
IntlDateFormatter::getTimeZoneId
datefmt_get_timezone_id
Get the timezone-id used for the IntlDateFormatter
说明
面向对象风格
public string IntlDateFormatter::getTimeZoneId ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">datefmt_get_timezone_id ( <span
class="methodparam">IntlDateFormatter
$fmt
)
Get the timezone-id used for the IntlDateFormatter.
参数
fmt
The formatter resource.
返回值
ID string for the time zone used by this formatter.
范例
示例 #1 datefmt_get_timezone_id example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'timezone_id of the formatter is : ' . datefmt_get_timezone_id($fmt);
datefmt_set_timezone_id($fmt, 'CN');
echo 'Now timezone_id of the formatter is : ' . datefmt_get_timezone_id($fmt);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'timezone_id of the formatter is : ' . $fmt->getTimezoneId();
$fmt->setTimezoneId('CN');
echo 'Now timezone_id of the formatter is : ' . $fmt->getTimezoneId();
?>
以上例程会输出:
timezone_id of the formatter is : America/Los_Angeles
Now timezone_id of the formatter is : CN
参见
- datefmt_set_timezone_id
- datefmt_create
IntlDateFormatter::getCalendarObject
datefmt_get_calendar_object
Get copy of formatterʼs calendar object
说明
面向对象风格
public <span class="type">IntlCalendar <span class="methodname">IntlDateFormatter::getCalendarObject ( <span class="methodparam">void )
过程化风格
IntlCalendar <span class="methodname">datefmt_get_calendar_object ( <span class="methodparam">void )
Obtain a copy of the calendar object used internally by this formatter. This calendar will have a type (as in gregorian, japanese, buddhist, roc, persian, islamic, etc.) and a timezone that match the type and timezone used by the formatter. The date/time of the object is unspecified.
参数
此函数没有参数。
返回值
A copy of the internal calendar object used by this formatter.
范例
示例 #1 <span class="function">IntlDateFormatter::getCalendarObject example
<?php
$formatter = IntlDateFormatter::create(
"fr_FR@calendar=islamic",
NULL,
NULL,
"GMT-01:00",
IntlDateFormatter::TRADITIONAL
);
$cal = $formatter->getCalendarObject();
var_dump(
$cal->getType(),
$cal->getTimeZone(),
$cal->getLocale(Locale::VALID_LOCALE)
);
以上例程会输出:
string(7) "islamic"
object(IntlTimeZone)#3 (4) {
["valid"]=>
bool(true)
["id"]=>
string(9) "GMT-01:00"
["rawOffset"]=>
int(-3600000)
["currentOffset"]=>
int(-3600000)
}
string(5) "fr_FR"
参见
- IntlDateFormatter::getCalendar
- IntlDateFormatter::setCalendar
- IntlCalendar
IntlDateFormatter::getTimeZone
datefmt_get_timezone
Get formatterʼs timezone
说明
面向对象风格
public <span class="type">IntlTimeZonefalse IntlDateFormatter::getTimeZone ( <span class="methodparam">void )
过程化风格
IntlTimeZone<span class="type">false <span class="methodname">datefmt_get_timezone ( <span class="methodparam">void )
Returns an IntlTimeZone object representing the timezone that will be used by this object to format dates and times. When formatting <span class="classname">IntlCalendar and <span class="classname">DateTime objects with this <span class="classname">IntlDateFormatter, the timezone used will be the one returned by this method, not the one associated with the objects being formatted.
参数
此函数没有参数。
返回值
The associated IntlTimeZone object
或者在失败时返回 false
.
范例
示例 #1 IntlDateFormatter::getTimeZone examples
<?php
$madrid = IntlDateFormatter::create(NULL, NULL, NULL, 'Europe/Madrid');
$lisbon = IntlDateFormatter::create(NULL, NULL, NULL, 'Europe/Lisbon');
var_dump($madrid->getTimezone());
echo $madrid->getTimezone()->getDisplayName(
false, IntlTimeZone::DISPLAY_GENERIC_LOCATION, "en_US"), "\n";
echo $lisbon->getTimeZone()->getId(), "\n";
//The id can also be retrieved with ->getTimezoneId()
echo $lisbon->getTimeZoneId(), "\n";
以上例程会输出:
object(IntlTimeZone)#4 (4) {
["valid"]=>
bool(true)
["id"]=>
string(13) "Europe/Madrid"
["rawOffset"]=>
int(3600000)
["currentOffset"]=>
int(7200000)
}
Spain Time
Europe/Lisbon
Europe/Lisbon
参见
- IntlDateFormatter::getTimeZoneId
- IntlDateFormatter::setTimeZone
- IntlTimeZone
IntlDateFormatter::isLenient
datefmt_is_lenient
Get the lenient used for the IntlDateFormatter
说明
面向对象风格
public bool IntlDateFormatter::isLenient ( <span class="methodparam">void )
过程化风格
bool <span
class="methodname">datefmt_is_lenient ( <span
class="methodparam">IntlDateFormatter
$fmt
)
Check if the parser is strict or lenient in interpreting inputs that do not match the pattern exactly.
参数
fmt
The formatter resource.
返回值
true
if parser is lenient, false
if parser is strict. By
default the parser is lenient.
范例
示例 #1 datefmt_is_lenient example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'dd/mm/yyyy'
);
echo 'lenient of the formatter is : ';
if ($fmt->isLenient()) {
echo 'TRUE';
} else {
echo 'FALSE';
}
datefmt_parse($fmt, '35/13/1971');
echo "\n Trying to do parse('35/13/1971').\nResult is : " . datefmt_parse($fmt, '35/13/1971');
if (intl_get_error_code() != 0) {
echo "\nError_msg is : " . intl_get_error_message();
echo "\nError_code is : " . intl_get_error_code();
}
datefmt_set_lenient($fmt,false);
echo 'Now lenient of the formatter is : ';
if ($fmt->isLenient()) {
echo 'TRUE';
} else {
echo 'FALSE';
}
datefmt_parse($fmt, '35/13/1971');
echo "\n Trying to do parse('35/13/1971').Result is : " . datefmt_parse($fmt, '35/13/1971');
if (intl_get_error_code() != 0) {
echo "\nError_msg is : " . intl_get_error_message();
echo "\nError_code is : " . intl_get_error_code();
}
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
"dd/mm/yyyy"
);
echo "lenient of the formatter is : ";
if ($fmt->isLenient()) {
echo 'TRUE';
} else {
echo 'FALSE';
}
$fmt->parse('35/13/1971');
echo "\n Trying to do parse('35/13/1971').\nResult is : " . $fmt->parse('35/13/1971');
if (intl_get_error_code() != 0){
echo "\nError_msg is : " . intl_get_error_message();
echo "\nError_code is : " . intl_get_error_code();
}
$fmt->setLenient(FALSE);
echo 'Now lenient of the formatter is : ';
if ($fmt->isLenient()) {
echo 'TRUE';
} else {
echo 'FALSE';
}
$fmt->parse('35/13/1971');
echo "\n Trying to do parse('35/13/1971').\nResult is : " . $fmt->parse('35/13/1971');
if (intl_get_error_code() != 0) {
echo "\nError_msg is : " . intl_get_error_message();
echo "\nError_code is : " . intl_get_error_code();
}
?>
以上例程会输出:
lenient of the formatter is : TRUE
Trying to do parse('35/13/1971').
Result is : -2147483
Now lenient of the formatter is : FALSE
Trying to do parse('35/13/1971').
Result is :
Error_msg is : Date parsing failed: U_PARSE_ERROR
Error_code is : 9
参见
- datefmt_set_lenient
- datefmt_create
IntlDateFormatter::localtime
datefmt_localtime
Parse string to a field-based time value
说明
面向对象风格
public array
IntlDateFormatter::localtime ( <span
class="methodparam">string $value
[,
int
&$position
] )
过程化风格
array <span
class="methodname">datefmt_localtime ( <span
class="methodparam">IntlDateFormatter
$fmt
, <span
class="type">string $value
[, <span
class="methodparam">int &$position
]
)
Converts string $value to a field-based time value ( an array of various fields), starting at $parse_pos and consuming as much of the input value as possible.
参数
fmt
The formatter resource
value
string to convert to a time
position
Position at which to start the parsing in $value (zero-based). If no
error occurs before $value is consumed, $parse_pos will contain -1
otherwise it will contain the position at which parsing ended . If
$parse_pos > strlen($value), the parse fails immediately.
返回值
Localtime compatible array of integers : contains 24 hour clock value in tm_hour field
范例
示例 #1 datefmt_localtime example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
$arr = datefmt_localtime($fmt, 'Wednesday, December 31, 1969 4:00:00 PM PT', 0);
echo 'First parsed output is ';
if ($arr) {
foreach ($arr as $key => $value) {
echo "$key : $value , ";
}
}
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
$arr = $fmt->localtime('Wednesday, December 31, 1969 4:00:00 PM PT', 0);
echo 'First parsed output is ';
if ($arr) {
foreach ($arr as $key => $value) {
echo "$key : $value , ";
}
}
?>
以上例程会输出:
First parsed output is tm_sec : 0 , tm_min : 0 , tm_hour : 16 , tm_year : 1969 ,
tm_mday : 31 , tm_wday : 4 , tm_yday : 365 , tm_mon : 11 , tm_isdst : 0 ,
参见
- datefmt_create
- datefmt_format
- datefmt_parse
- datefmt_get_error_code
- datefmt_get_error_message
IntlDateFormatter::parse
datefmt_parse
Parse string to a timestamp value
说明
面向对象风格
public int <span
class="methodname">IntlDateFormatter::parse ( <span
class="methodparam">string $value
[,
int
&$position
] )
过程化风格
int <span
class="methodname">datefmt_parse ( <span
class="methodparam">IntlDateFormatter
$fmt
, <span
class="type">string $value
[, <span
class="methodparam">int &$position
]
)
Converts string $value to an incremental time value, starting at $parse_pos and consuming as much of the input value as possible.
参数
fmt
The formatter resource
value
string to convert to a time
position
Position at which to start the parsing in $value (zero-based). If no
error occurs before $value is consumed, $parse_pos will contain -1
otherwise it will contain the position at which parsing ended (and the
error occurred). This variable will contain the end position if the
parse fails. If $parse_pos > strlen($value), the parse fails
immediately.
返回值
timestamp parsed value, or false
if value can't be parsed.
范例
示例 #1 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'First parsed output is ' . $fmt->parse('Wednesday, December 20, 1989 4:00:00 PM PT');
$fmt = new IntlDateFormatter(
'de-DE',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
?>
示例 #2 datefmt_parse example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'First parsed output is ' . datefmt_parse($fmt, 'Wednesday, December 20, 1989 4:00:00 PM PT');
$fmt = datefmt_create(
'de-DE',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'Second parsed output is ' . datefmt_parse($fmt, 'Mittwoch, 20. Dezember 1989 16:00 Uhr GMT-08:00');
?
以上例程会输出:
First parsed output is 630201600
Second parsed output is 630201600
参见
- datefmt_create
- datefmt_format
- datefmt_localtime
- datefmt_get_error_code
- datefmt_get_error_message
IntlDateFormatter::setCalendar
datefmt_set_calendar
Sets the calendar type used by the formatter
说明
面向对象风格
public bool
IntlDateFormatter::setCalendar ( <span
class="methodparam">mixed $which
)
过程化风格
bool <span
class="methodname">datefmt_set_calendar ( <span
class="methodparam">IntlDateFormatter
$fmt
, <span
class="type">mixed $which
)
Sets the calendar or calendar type used by the formatter.
参数
fmt
The formatter resource.
which
This can either be: the
calendar type
to use (default is IntlDateFormatter::GREGORIAN
, which is also
used if null
is specified) or an <span
class="classname">IntlCalendar object.
Any IntlCalendar object passed in will be cloned; no modifications will be made to the argument object.
The timezone of the formatter will only be kept if an <span class="classname">IntlCalendar object is not passed, otherwise the new timezone will be that of the passed object.
返回值
成功时返回 true
, 或者在失败时返回 false
。
更新日志
版本 | 说明 |
---|---|
5.5.0/PECL 3.0.0 | It became possible to pass an IntlCalendar object. |
范例
示例 #1 datefmt_set_calendar example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'calendar of the formatter is : ' . datefmt_get_calendar($fmt);
datefmt_set_calendar($fmt, IntlDateFormatter::TRADITIONAL);
echo 'Now calendar of the formatter is : ' . datefmt_get_calendar($fmt);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'calendar of the formatter is : ' . $fmt->getCalendar();
$fmt->setCalendar(IntlDateFormatter::TRADITIONAL);
echo 'Now calendar of the formatter is : ' . $fmt->getCalendar();
?>
以上例程会输出:
calendar of the formatter is : 1
Now calendar of the formatter is : 0
示例 #3 Example with IntlCalendar argument
<?php
$time = strtotime("2013-03-03 00:00:00 UTC");
$formatter = IntlDateFormatter::create("en_US", NULL, NULL, "Europe/Amsterdam");
echo "before: ", $formatter->format($time), "\n";
/* note that the calendar's locale is not used! */
$formatter->setCalendar(IntlCalendar::createInstance(
"America/New_York", "pt_PT@calendar=islamic"));
echo "after: ", $formatter->format($time), "\n";
以上例程会输出:
before: Sunday, March 3, 2013 at 1:00:00 AM Central European Standard Time
after: Saturday, Rabiʻ II 20, 1434 at 7:00:00 PM Eastern Standard Time
参见
- datefmt_get_calendar
- datefmt_get_calendar_object
- datefmt_create
IntlDateFormatter::setLenient
datefmt_set_lenient
Set the leniency of the parser
说明
面向对象风格
public bool
IntlDateFormatter::setLenient ( <span
class="methodparam">bool $lenient
)
过程化风格
bool <span
class="methodname">datefmt_set_lenient ( <span
class="methodparam">IntlDateFormatter
$fmt
, bool
$lenient
)
Define if the parser is strict or lenient in interpreting inputs that do not match the pattern exactly. Enabling lenient parsing allows the parser to accept otherwise flawed date or time patterns, parsing as much as possible to obtain a value. Extra space, unrecognized tokens, or invalid values ("February 30th") are not accepted.
参数
fmt
The formatter resource
lenient
Sets whether the parser is lenient or not, default is true
(lenient).
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 datefmt_set_lenient example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'dd/MM/yyyy'
);
echo 'lenient of the formatter is : ';
if ($fmt->isLenient()) {
echo 'TRUE';
} else {
echo 'FALSE';
}
datefmt_parse($fmt, '35/13/1971');
echo "\n Trying to do parse('35/13/1971').\nResult is : " . datefmt_parse($fmt, '35/13/1971');
if (intl_get_error_code() != 0) {
echo "\nError_msg is : " . intl_get_error_message();
echo "\nError_code is : " . intl_get_error_code();
}
datefmt_set_lenient($fmt, false);
echo "\nNow lenient of the formatter is : ";
if ($fmt->isLenient()) {
echo 'TRUE';
} else {
echo 'FALSE';
}
datefmt_parse($fmt, '35/13/1971');
echo "\nTrying to do parse('35/13/1971').\nResult is : " . datefmt_parse($fmt, '35/13/1971');
if (intl_get_error_code() != 0) {
echo "\nError_msg is : ".intl_get_error_message();
echo "\nError_code is : ".intl_get_error_code();
}
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'dd/MM/yyyy'
);
echo 'lenient of the formatter is : ';
if ($fmt->isLenient()) {
echo 'TRUE';
} else {
echo 'FALSE';
}
$fmt->parse('35/13/1971');
echo "\n Trying to do parse('35/13/1971').\nResult is : " . $fmt->parse('35/13/1971');
if (intl_get_error_code() != 0) {
echo "\nError_msg is : " . intl_get_error_message();
echo "\nError_code is : " . intl_get_error_code();
}
$fmt->setLenient(FALSE);
echo "\nNow lenient of the formatter is : ";
if ($fmt->isLenient()) {
echo 'TRUE';
} else {
echo 'FALSE';
}
$fmt->parse('35/13/1971');
echo "\n Trying to do parse('35/13/1971').\nResult is : " . $fmt->parse('35/13/1971');
if (intl_get_error_code() != 0) {
echo "\nError_msg is : " . intl_get_error_message();
echo "\nError_code is : " . intl_get_error_code();
}
?>
以上例程会输出:
lenient of the formatter is : TRUE
Trying to do parse('35/13/1971').
Result is : 66038400
Now lenient of the formatter is : FALSE
Trying to do parse('35/13/1971').
Result is :
Error_msg is : Date parsing failed: U_PARSE_ERROR
Error_code is : 9
参见
- datefmt_is_lenient
- datefmt_create
IntlDateFormatter::setPattern
datefmt_set_pattern
Set the pattern used for the IntlDateFormatter
说明
面向对象风格
public bool
IntlDateFormatter::setPattern ( <span
class="methodparam">string $pattern
)
过程化风格
bool <span
class="methodname">datefmt_set_pattern ( <span
class="methodparam">IntlDateFormatter
$fmt
, <span
class="type">string $pattern
)
Set the pattern used for the IntlDateFormatter.
参数
fmt
The formatter resource.
pattern
New pattern string to use. Possible patterns are documented at
» http://userguide.icu-project.org/formatparse/datetime.
返回值
成功时返回 true
, 或者在失败时返回 false
。 Bad formatstrings
are usually the cause of the failure.
范例
示例 #1 datefmt_set_pattern example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo 'pattern of the formatter is : ' . datefmt_get_pattern($fmt);
echo 'First Formatted output with pattern is ' . datefmt_format($fmt, 0);
datefmt_set_pattern($fmt, 'yyyymmdd hh:mm:ss z');
echo 'Now pattern of the formatter is : ' . datefmt_get_pattern($fmt);
echo 'Second Formatted output with pattern is ' . datefmt_format($fmt, 0);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN,
'MM/dd/yyyy'
);
echo 'pattern of the formatter is : ' . $fmt->getPattern();
echo 'First Formatted output is ' . $fmt->format(0);
$fmt->setPattern('yyyymmdd hh:mm:ss z');
echo 'Now pattern of the formatter is : ' . $fmt->getPattern();
echo 'Second Formatted output is ' . $fmt->format(0);
?>
以上例程会输出:
pattern of the formatter is : MM/dd/yyyy
First Formatted output with pattern is 12/31/1969
Now pattern of the formatter is : yyyymmdd hh:mm:ss z
Second Formatted output with pattern is 19690031 04:00:00 PST
参见
- datefmt_get_pattern
- datefmt_create
IntlDateFormatter::setTimeZoneId
datefmt_set_timezone_id
Sets the time zone to use
Warning
This function was DEPRECATED in PHP 5.5.0, and REMOVED in PHP 7.0.0.
Alternatives to this function include:
- IntlDateFormatter::setTimeZone
说明
面向对象风格
public bool
IntlDateFormatter::setTimeZoneId ( <span
class="methodparam">string $zone
)
过程化风格
bool <span
class="methodname">datefmt_set_timezone_id ( <span
class="methodparam">IntlDateFormatter
$fmt
, <span
class="type">string $zone
)
Sets the time zone to use.
参数
fmt
The formatter resource.
zone
The time zone ID string of the time zone to use. If null
or the
empty string, the default time zone for the runtime is used.
返回值
成功时返回 true
, 或者在失败时返回 false
。
更新日志
版本 | 说明 |
---|---|
7.0.0 | This function has been removed. |
5.5.0 | This function has been deprecated. |
范例
示例 #1 datefmt_set_timezone_id example
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'timezone_id of the formatter is : ' . datefmt_get_timezone_id($fmt);
datefmt_set_timezone_id($fmt, 'CN');
echo 'Now timezone_id of the formatter is : ' . datefmt_get_timezone_id($fmt);
?>
示例 #2 OO example
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'timezone_id of the formatter is : ' . $fmt->getTimezoneId();
$fmt->setTimezoneId('CN');
echo 'Now timezone_id of the formatter is : ' . $fmt->getTimezoneId();
?>
以上例程会输出:
timezone_id of the formatter is : America/Los_Angeles
Now timezone_id of the formatter is : CN
参见
- datefmt_get_timezone_id
- datefmt_create
IntlDateFormatter::setTimeZone
datefmt_set_timezone
Sets formatterʼs timezone
说明
面向对象风格
public bool
IntlDateFormatter::setTimeZone ( <span
class="methodparam">mixed $zone
)
过程化风格
bool <span
class="methodname">datefmt_set_timezone ( <span
class="methodparam">IntlDateFormatter
$fmt
, <span
class="type">mixed $zone
)
Sets the timezone used for the IntlDateFormatter. object.
参数
fmt
The formatter resource.
zone
The timezone to use for this formatter. This can be specified in the
following forms:
-
null
, in which case the default timezone will be used, as specified in the ini setting date.timezone or through the function <span class="function">date_default_timezone_set and as returned by date_default_timezone_get. -
An IntlTimeZone, which will be used directly.
-
A DateTimeZone. Its identifier will be extracted and an ICU timezone object will be created; the timezone will be backed by ICUʼs database, not PHPʼs.
-
A string, which should be a valid ICU timezone identifier. See <span class="function">IntlTimeZone::createTimeZoneIDEnumeration. Raw offsets such as "GMT+08:30" are also accepted.
返回值
Returns true
on success and false
on failure.
范例
示例 #1 IntlDateFormatter::setTimeZone examples
<?php
ini_set('date.timezone', 'Europe/Amsterdam');
$formatter = IntlDateFormatter::create(NULL, NULL, NULL, "UTC");
$formatter->setTimeZone(NULL);
echo "NULL\n ", $formatter->getTimeZone()->getId(), "\n";
$formatter->setTimeZone(IntlTimeZone::createTimeZone('Europe/Lisbon'));
echo "IntlTimeZone\n ", $formatter->getTimeZone()->getId(), "\n";
$formatter->setTimeZone(new DateTimeZone('Europe/Paris'));
echo "DateTimeZone\n ", $formatter->getTimeZone()->getId(), "\n";
$formatter->setTimeZone('Europe/Rome');
echo "String\n ", $formatter->getTimeZone()->getId(), "\n";
$formatter->setTimeZone('GMT+00:30');
print_r($formatter->getTimeZone());
以上例程会输出:
NULL
Europe/Amsterdam
IntlTimeZone
Europe/Lisbon
DateTimeZone
Europe/Paris
String
Europe/Rome
IntlTimeZone Object
(
[valid] => 1
[id] => GMT+00:30
[rawOffset] => 1800000
[currentOffset] => 1800000
)
参见
- IntlDateFormatter::getTimeZone
简介
Localized software products often require sets of data that are to be customized depending on current locale, e.g.: messages, labels, formatting patterns. ICU resource mechanism allows to define sets of resources that the application can load on locale basis, while accessing them in unified locale-independent fashion.
This class implements access to ICU resource data files. These files are binary data arrays which ICU uses to store the localized data.
ICU resource bundle can hold simple resources and complex resources. Complex resources are containers which can be either integer-indexed or string-indexed (just like PHP arrays). Simple resources can be of the following types: string, integer, binary data field or integer array.
ResourceBundle supports direct access to the data through array access pattern and iteration via foreach, as well as access via class methods. The result will be PHP value for simple resources and ResourceBundle object for complex ones. All resources are read-only.
类摘要
ResourceBundle
class ResourceBundle {
/* Methods */
public <span
class="methodname">__construct ( <span
class="methodparam">string $locale
,
string
$bundlename
[, <span
class="type">bool $fallback
] )
public int <span class="methodname">count ( void )
public <span
class="modifier">static ResourceBundle
create ( <span
class="type">string $locale
, <span
class="methodparam">string
$bundlename
[, <span
class="type">bool $fallback
] )
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
public mixed
get ( <span
class="type">string<span
class="type">int $index
[, <span
class="methodparam">bool $fallback
<span
class="initializer"> = true
] )
public array
getLocales ( <span
class="methodparam">string
$bundlename
)
}
参见
ResourceBundle::count
resourcebundle_count
Get number of elements in the bundle
说明
面向对象风格
public int <span class="methodname">ResourceBundle::count ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">resourcebundle_count ( <span
class="methodparam">ResourceBundle $r
)
Get the number of elements in the bundle.
参数
r
ResourceBundle object.
返回值
Returns number of elements in the bundle.
范例
示例 #1 resourcebundle_count example
<?php
$r = resourcebundle_create( 'es', "/usr/share/data/myapp");
echo resourcebundle_count($r);
?>
示例 #2 OO example
<?php
$r = new ResourceBundle( 'es', "/usr/share/data/myapp");
echo $r->count();
?>
以上例程会输出:
42
参见
- resourcebundle_get
ResourceBundle::create
resourcebundle_create
ResourceBundle::__construct
Create a resource bundle
说明
面向对象风格 (method)
public <span
class="modifier">static ResourceBundle
ResourceBundle::create ( <span
class="methodparam">string $locale
,
string
$bundlename
[, <span
class="type">bool $fallback
] )
过程化风格
ResourceBundle <span
class="methodname">resourcebundle_create ( <span
class="methodparam">string $locale
,
string
$bundlename
[, <span
class="type">bool $fallback
] )
面向对象风格 (constructor):
public <span
class="methodname">ResourceBundle::__construct ( <span
class="methodparam">string $locale
,
string
$bundlename
[, <span
class="type">bool $fallback
] )
Creates a resource bundle.
参数
locale
Locale for which the resources should be loaded (locale name, e.g.
en_CA).
bundlename
The directory where the data is stored or the name of the .dat file.
fallback
Whether locale should match exactly or fallback to parent locale is
allowed.
返回值
Returns ResourceBundle object or
null
on error.
范例
示例 #1 resourcebundle_create example
<?php
$r = resourcebundle_create( 'es', "/usr/share/data/myapp");
echo $r['teststring'];
?>
示例 #2 ResourceBundle::create example
<?php
$r = ResourceBundle::create( 'es', "/usr/share/data/myapp");
echo $r['teststring'];
?>
以上例程会输出:
¡Hola, mundo!
参见
- resourcebundle_get
ResourceBundle::getErrorCode
resourcebundle_get_error_code
Get bundle's last error code
说明
面向对象风格
public int <span class="methodname">ResourceBundle::getErrorCode ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">resourcebundle_get_error_code ( <span
class="methodparam">ResourceBundle $r
)
Get error code from the last function performed by the bundle object.
参数
r
ResourceBundle object.
返回值
Returns error code from last bundle object call.
范例
示例 #1 <span class="function">resourcebundle_get_error_code example
<?php
$r = resourcebundle_create( 'es', "/usr/share/data/myapp");
echo $r['somestring'];
if(intl_is_failure(resourcebundle_get_error_code($r))) {
report_error("Bundle error");
}
?>
示例 #2 OO example
<?php
$r = new ResourceBundle( 'es', "/usr/share/data/myapp");
echo $r['somestring'];
if(intl_is_failure(ResourceBundle::getErrorCode($r))) {
report_error("Bundle error");
}
?>
参见
- resourcebundle_get_error_message
- intl_get_error_code
- intl_is_failure
ResourceBundle::getErrorMessage
resourcebundle_get_error_message
Get bundle's last error message
说明
面向对象风格
public string ResourceBundle::getErrorMessage ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">resourcebundle_get_error_message ( <span
class="methodparam">ResourceBundle $r
)
Get error message from the last function performed by the bundle object.
参数
r
ResourceBundle object.
返回值
Returns error message from last bundle object's call.
范例
示例 #1 <span class="function">resourcebundle_get_error_message example
<?php
$r = resourcebundle_create( 'es', "/usr/share/data/myapp");
echo $r['somestring'];
if(intl_is_failure(resourcebundle_get_error_code($r))) {
report_error("Bundle error: ".resourcebundle_get_error_message($r));
}
?>
示例 #2 OO example
<?php
$r = new ResourceBundle( 'es', "/usr/share/data/myapp");
echo $r['somestring'];
if(intl_is_failure(ResourceBundle::getErrorCode($r))) {
report_error("Bundle error: ".ResourceBundle::getErrorMessage($r));
}
?>
参见
- resourcebundle_get_error_code
- intl_get_error_code
- intl_is_failure
ResourceBundle::get
resourcebundle_get
Get data from the bundle
说明
面向对象风格
public mixed
ResourceBundle::get ( <span
class="methodparam"><span
class="type">stringint
$index
[, <span
class="type">bool $fallback
=
true
] )
过程化风格
mixed <span
class="methodname">resourcebundle_get ( <span
class="methodparam">ResourceBundle $r
, <span
class="type">stringint
$index
[, <span
class="type">bool $fallback
=
true
] )
Get the data from the bundle by index or string key.
参数
r
ResourceBundle object.
index
Data index, must be string or integer.
fallback
Whether locale should match exactly or fallback to parent locale is
allowed.
返回值
Returns the data located at the index or null
on error. Strings,
integers and binary data strings are returned as corresponding PHP
types, integer array is returned as PHP array. Complex types are
returned as ResourceBundle object.
范例
示例 #1 resourcebundle_get example
<?php
$r = resourcebundle_create( 'es', "/usr/share/data/myapp");
echo resourcebundle_get($r, 'somestring');
?>
示例 #2 OO example
<?php
$r = new ResourceBundle( 'es', "/usr/share/data/myapp");
echo $r->get('somestring');
?>
以上例程会输出:
?Hola, mundo!
参见
- resourcebundle_count
ResourceBundle::getLocales
resourcebundle_locales
Get supported locales
说明
面向对象风格
public array
ResourceBundle::getLocales ( <span
class="methodparam">string
$bundlename
)
过程化风格
array <span
class="methodname">resourcebundle_locales ( <span
class="methodparam">string
$bundlename
)
Get available locales from ResourceBundle name.
参数
bundlename
Path of ResourceBundle for which to get available locales, or empty
string for default locales list.
返回值
Returns the list of locales supported by the bundle.
范例
示例 #1 resourcebundle_locales example
<?php
$bundle = "/user/share/data/myapp";
echo join(PHP_EOL, resourcebundle_locales($bundle));
?>
以上例程的输出类似于:
es
root
示例 #2 OO example
<?php
$bundle = "/usr/share/data/myapp";
$r = new ResourceBundle( 'es', $bundle);
echo join("\n", $r->getLocales($bundle));
?>
以上例程的输出类似于:
es
root
参见
- resourcebundle_get
简介
This class is provided because Unicode contains large number of characters and incorporates the varied writing systems of the world and their incorrect usage can expose programs or systems to possible security attacks using characters similarity.
Provided methods allow to check whether an individual string is likely an attempt at confusing the reader (spoof detection), such as "pаypаl" spelled with Cyrillic 'а' characters.
类摘要
Spoofchecker
class Spoofchecker {
/* Constants */
const <span
class="type">intfloat
Spoofchecker::ASCII
= 0x10000000 ;
const <span
class="type">intfloat
Spoofchecker::HIGHLY_RESTRICTIVE
=
0x30000000 ;
const <span
class="type">intfloat
Spoofchecker::MODERATELY_RESTRICTIVE
=
0x40000000 ;
const <span
class="type">intfloat
Spoofchecker::MINIMALLY_RESTRICTIVE
=
0x50000000 ;
const <span
class="type">intfloat
Spoofchecker::UNRESTRICTIVE
=
0x60000000 ;
const <span
class="type">intfloat
Spoofchecker::SINGLE_SCRIPT_RESTRICTIVE
=
0x20000000 ;
const int
Spoofchecker::SINGLE_SCRIPT_CONFUSABLE
=
1 ;
const int
Spoofchecker::MIXED_SCRIPT_CONFUSABLE
=
2 ;
const int
Spoofchecker::WHOLE_SCRIPT_CONFUSABLE
=
4 ;
const int
Spoofchecker::ANY_CASE
= 8 ;
const int
Spoofchecker::SINGLE_SCRIPT
= 16 ;
const int
Spoofchecker::INVISIBLE
= 32 ;
const int
Spoofchecker::CHAR_LIMIT
= 64 ;
/* 方法 */
public bool
areConfusable ( <span
class="methodparam">string $str1
,
string
$str2
[, <span
class="type">string &$error
] )
public <span class="methodname">__construct ( <span class="methodparam">void )
public bool
isSuspicious ( <span
class="methodparam">string $text
[,
string
&$error
] )
public void
setAllowedLocales ( <span
class="methodparam">string
$locale_list
)
public void
setChecks ( <span
class="methodparam">int $checks
)
}
预定义常量
Spoofchecker::ASCII
Spoofchecker::HIGHLY_RESTRICTIVE
Spoofchecker::MODERATELY_RESTRICTIVE
Spoofchecker::MINIMALLY_RESTRICTIVE
Spoofchecker::UNRESTRICTIVE
Spoofchecker::SINGLE_SCRIPT_RESTRICTIVE
Spoofchecker::SINGLE_SCRIPT_CONFUSABLE
Spoofchecker::MIXED_SCRIPT_CONFUSABLE
Spoofchecker::WHOLE_SCRIPT_CONFUSABLE
Spoofchecker::ANY_CASE
Spoofchecker::SINGLE_SCRIPT
Spoofchecker::INVISIBLE
Spoofchecker::CHAR_LIMIT
更新日志
版本 | 说明 |
---|---|
7.3.0 | Class constants used by Spoofchecker::setRestrictionLevel such as Spoofchecker::ASCII , Spoofchecker::HIGHLY_RESTRICTIVE , Spoofchecker::MODERATELY_RESTRICTIVE , Spoofchecker::MINIMALLY_RESTRICTIVE , Spoofchecker::UNRESTRICTIVE , Spoofchecker::SINGLE_SCRIPT_RESTRICTIVE has been added. |
Spoofchecker::areConfusable
Checks if given strings can be confused
说明
public bool
Spoofchecker::areConfusable ( <span
class="methodparam">string $str1
,
string
$str2
[, <span
class="type">string &$error
] )
Checks whether two given strings can easily be mistaken.
参数
str1
First string to check.
str2
Second string to check.
error
This variable is set by-reference to string containing an error, if
there were any.
返回值
Returns true
if two given strings can be confused, false
otherwise.
范例
示例 #1 Spoofchecker::areConfusable example
<?php
$checker = new Spoofchecker();
$checker->areConfusable('google.com', 'goog1e.com'); // true
// Lower l can be confused with digit one
$checker->areConfusable('google.com', 'g00g1e.com'); // false
// Zero (0) cannot be easily confused with "o" letter
Spoofchecker::__construct
Constructor
说明
public <span class="methodname">Spoofchecker::__construct ( <span class="methodparam">void )
Creates new instance of Spoofchecker.
参数
此函数没有参数。
返回值
Returns Spoofchecker instance.
Spoofchecker::isSuspicious
Checks if a given text contains any suspicious characters
说明
public bool
Spoofchecker::isSuspicious ( <span
class="methodparam">string $text
[,
string
&$error
] )
Checks if given string contains any suspicious characters like letters which are almost identical visually, but are Unicode characters from different sets.
参数
text
String to test.
error
This variable is set by-reference to string containing an error, if
there were any.
返回值
Returns true
if there are suspicious characters, false
otherwise.
范例
示例 #1 Spoofchecker::isSuspicious example
<?php
$checker = new Spoofchecker();
$checker->isSuspicious('google.com'); // FALSE: only ASCII characters
$checker->isSuspicious('Рaypal.com'); // TRUE
// The first letter is from Cyrylic, not a regular latin "P"
Spoofchecker::setAllowedLocales
Locales to use when running checks
说明
public void
Spoofchecker::setAllowedLocales ( <span
class="methodparam">string
$locale_list
)
Warning
本函数还未编写文档,仅有参数列表。
参数
locale_list
返回值
Spoofchecker::setChecks
Set the checks to run
说明
public void
Spoofchecker::setChecks ( <span
class="methodparam">int $checks
)
Warning
本函数还未编写文档,仅有参数列表。
参数
checks
返回值
简介
Transliterator provides transliteration of strings.
类摘要
Transliterator
class Transliterator {
/* 常量 */
const int
Transliterator::FORWARD
= 0 ;
const int
Transliterator::REVERSE
= 1 ;
/* 属性 */
public $id
;
/* 方法 */
private <span class="methodname">__construct ( <span class="methodparam">void )
public <span
class="modifier">static Transliterator
create ( <span
class="type">string $id
[, <span
class="methodparam">int $direction
]
)
public <span
class="modifier">static Transliterator
createFromRules ( <span
class="methodparam">string $rules
[,
string
$direction
] )
public <span class="type">Transliterator <span class="methodname">createInverse ( <span class="methodparam">void )
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
public <span class="modifier">static <span class="type">arrayfalse <span class="methodname">listIDs ( <span class="methodparam">void )
public <span
class="type">stringfalse <span
class="methodname">transliterate ( <span
class="methodparam">string $subject
[, int
$start
[, <span
class="type">int $end
]] )
}
属性
id
预定义常量
Transliterator::FORWARD
Transliterator::REVERSE
Transliterator::__construct
Private constructor to deny instantiation
说明
private <span class="methodname">Transliterator::__construct ( <span class="methodparam">void )
This method should not be called. Its only purpose is to deny instantiation with the new operator.
Use the factory methods <span class="methodname">Transliterator::create or <span class="methodname">Transliterator::createFromRules instead.
参数
此函数没有参数。
返回值
This method should not be executed. If it is (e.g. through reflection), then its return value is unspecified.
参见
- Transliterator::create
- Transliterator::createFromRules
Transliterator::create
transliterator_create
Create a transliterator
说明
面向对象风格
public <span
class="modifier">static Transliterator
Transliterator::create ( <span
class="methodparam">string $id
[,
int
$direction
] )
过程化风格
Transliterator <span
class="methodname">transliterator_create ( <span
class="methodparam">string $id
[,
int
$direction
] )
Opens a Transliterator by ID.
Warning
本函数还未编写文档,仅有参数列表。
参数
id
The ID. A list of all registered transliterator IDs can be retrieved by
using Transliterator::listIDs.
direction
The direction, defaults to
Transliterator::FORWARD.
May also be set to
Transliterator::REVERSE.
返回值
Returns a Transliterator object on
success, or null
on failure.
参见
- Transliterator::getErrorMessage
- Transliterator::__construct
Transliterator::createFromRules
transliterator_create_from_rules
Create transliterator from rules
说明
面向对象风格
public <span
class="modifier">static Transliterator
Transliterator::createFromRules ( <span
class="methodparam">string $rules
[,
string
$direction
] )
过程化风格
Transliterator <span
class="methodname">transliterator_create_from_rules ( <span
class="methodparam">string $id
[,
int
$direction
] )
Creates a Transliterator from rules.
Warning
本函数还未编写文档,仅有参数列表。
参数
rules
The rules as defined in Transform Rules Syntax of UTS #35: Unicode
LDML.
direction
The direction, defaults to
>Transliterator::FORWARD.
May also be set to
Transliterator::REVERSE.
返回值
Returns a Transliterator object on
success, or null
on failure.
参见
- Transliterator::getErrorMessage
- Transliterator::create
Transliterator::createInverse
transliterator_create_inverse
Create an inverse transliterator
说明
面向对象风格
public <span class="type">Transliterator <span class="methodname">Transliterator::createInverse ( <span class="methodparam">void )
过程化风格
Transliterator <span class="methodname">transliterator_create_inverse ( <span class="methodparam">void )
Opens the inverse transliterator.
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
Returns a Transliterator object on
success, or null
on failure
参见
- Transliterator::getErrorMessage
- Transliterator::create
Transliterator::getErrorCode
transliterator_get_error_code
Get last error code
说明
面向对象风格
public int <span class="methodname">Transliterator::getErrorCode ( <span class="methodparam">void )
过程化风格
int <span
class="methodname">transliterator_get_error_code ( <span
class="methodparam">Transliterator
$trans
)
Gets the last error code for this transliterator.
Warning
本函数还未编写文档,仅有参数列表。
参数
trans
返回值
The error code on success, or false
if none exists, or on failure.
参见
- Transliterator::getErrorMessage
- Transliterator::listIDs
Transliterator::getErrorMessage
transliterator_get_error_message
Get last error message
说明
面向对象风格
public string Transliterator::getErrorMessage ( <span class="methodparam">void )
过程化风格
string <span
class="methodname">transliterator_get_error_message ( <span
class="methodparam">Transliterator
$trans
)
Gets the last error message for this transliterator.
Warning
本函数还未编写文档,仅有参数列表。
参数
trans
返回值
The error message on success, or false
if none exists, or on
failure.
参见
- Transliterator::getErrorCode
- Transliterator::listIDs
Transliterator::listIDs
transliterator_list_ids
Get transliterator IDs
说明
面向对象风格
public <span class="modifier">static <span class="type">arrayfalse <span class="methodname">Transliterator::listIDs ( <span class="methodparam">void )
过程化风格
array<span class="type">false <span class="methodname">transliterator_list_ids ( <span class="methodparam">void )
Returns an array with the registered transliterator IDs.
参数
此函数没有参数。
返回值
An array of registered transliterator IDs on
success, 或者在失败时返回 false
.
范例
示例 #1 Retrieving the registered transliterator IDs
<?php
print_r(Transliterator::listIDs());
?>
以上例程的输出类似于:
Array
(
[0] => ASCII-Latin
[1] => Accents-Any
[2] => Amharic-Latin/BGN
[3] => Any-Accents
[4] => Any-Publishing
...
[650] => Any-ps_Latn/BGN
[651] => Any-tk/BGN
[652] => Any-ch_FONIPA
[653] => Any-cs_FONIPA
[654] => Any-cy_FONIPA
)
参见
- Transliterator::getErrorMessage
- Transliterator::transliterate
Transliterator::transliterate
transliterator_transliterate
Transliterate a string
说明
面向对象风格
public <span
class="type">stringfalse <span
class="methodname">Transliterator::transliterate ( <span
class="methodparam">string $subject
[, int
$start
[, <span
class="type">int $end
]] )
过程化风格
transliterator_transliterate ( <span
class="methodparam">mixed
$transliterator
, <span
class="type">string $subject
[, <span
class="methodparam">int $start
[,
int $end
]] )
Transforms a string or part thereof using an ICU transliterator.
参数
transliterator
In the procedural version, either a <span
class="classname">Transliterator or a <span
class="type">string from which a <span
class="classname">Transliterator can be built.
subject
The string to be transformed.
start
The start index (in UTF-16 code units) from which the string will start
to be transformed, inclusive. Indexing starts at 0. The text before will
be left as is.
end
The end index (in UTF-16 code units) until which the string will be
transformed, exclusive. Indexing starts at 0. The text after will be
left as is.
返回值
The transformed string on success, 或者在失败时返回 false
.
范例
示例 #1 Converting escaped UTF-16 code units
<?php
$s = "\u304A\u65E9\u3046\u3054\u3056\u3044\u307E\u3059";
echo transliterator_transliterate("Hex-Any/Java", $s), "\n";
//now the reverse operation with a supplementary character
$supplChar = html_entity_decode('𝄞');
echo mb_strlen($supplChar, "UTF-8"), "\n";
$encSupplChar = transliterator_transliterate("Any-Hex/Java", $supplChar);
//echoes two encoded UTF-16 code units
echo $encSupplChar, "\n";
//and back
echo transliterator_transliterate("Hex-Any/Java", $encSupplChar), "\n";
?>
以上例程的输出类似于:
お早うございます
1
\uD834\uDD1E
𝄞
参见
- Transliterator::getErrorMessage
- Transliterator::__construct
简介
A “break iterator” is an ICU object that exposes methods for locating boundaries in text (e.g. word or sentence boundaries). The PHP <span class="classname">IntlBreakIterator serves as the base class for all types of ICU break iterators. Where extra functionality is available, the intl extension may expose the ICU break iterator with suitable subclasses, such as <span class="classname">IntlRuleBasedBreakIterator or <span class="classname">IntlCodePointBreakIterator.
This class implements Traversable. Traversing an IntlBreakIterator yields non-negative integer values representing the successive locations of the text boundaries, expressed as UTF-8 code units (byte) counts, taken from the beginning of the text (which has the location 0). The keys yielded by the iterator simply form the sequence of natural numbers {0, 1, 2, …}.
类摘要
IntlBreakIterator
class IntlBreakIterator <span class="oointerface">implements <span class="interfacename">Traversable {
/* 常量 */
const int
IntlBreakIterator::DONE
= -1 ;
const int
IntlBreakIterator::WORD_NONE
= 0 ;
const int
IntlBreakIterator::WORD_NONE_LIMIT
=
100 ;
const int
IntlBreakIterator::WORD_NUMBER
= 100
;
const int
IntlBreakIterator::WORD_NUMBER_LIMIT
=
200 ;
const int
IntlBreakIterator::WORD_LETTER
= 200
;
const int
IntlBreakIterator::WORD_LETTER_LIMIT
=
300 ;
const int
IntlBreakIterator::WORD_KANA
= 300 ;
const int
IntlBreakIterator::WORD_KANA_LIMIT
=
400 ;
const int
IntlBreakIterator::WORD_IDEO
= 400 ;
const int
IntlBreakIterator::WORD_IDEO_LIMIT
=
500 ;
const int
IntlBreakIterator::LINE_SOFT
= 0 ;
const int
IntlBreakIterator::LINE_SOFT_LIMIT
=
100 ;
const int
IntlBreakIterator::LINE_HARD
= 100 ;
const int
IntlBreakIterator::LINE_HARD_LIMIT
=
200 ;
const int
IntlBreakIterator::SENTENCE_TERM
= 0
;
const int
IntlBreakIterator::SENTENCE_TERM_LIMIT
=
100 ;
const int
IntlBreakIterator::SENTENCE_SEP
=
100 ;
const int
IntlBreakIterator::SENTENCE_SEP_LIMIT
=
200 ;
/* 方法 */
private <span class="methodname">__construct ( <span class="methodparam">void )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">createCharacterInstance ([ <span
class="methodparam">string $locale
]
)
public <span class="modifier">static <span class="type">IntlBreakIterator <span class="methodname">createCodePointInstance ( <span class="methodparam">void )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">createLineInstance ([ <span
class="methodparam">string $locale
]
)
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">createSentenceInstance ([ <span
class="methodparam">string $locale
]
)
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">createTitleInstance ([ <span
class="methodparam">string $locale
]
)
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">createWordInstance ([ <span
class="methodparam">string $locale
]
)
public int <span class="methodname">current ( <span class="methodparam">void )
public int <span class="methodname">first ( void )
public int <span
class="methodname">following ( <span
class="type">int $offset
)
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
int <span class="methodname">intl_get_error_code ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
string <span class="methodname">intl_get_error_message ( <span class="methodparam">void )
public string
getLocale ( <span
class="methodparam">string
$locale_type
)
public <span
class="type">IntlPartsIterator <span
class="methodname">getPartsIterator ([ <span
class="methodparam">int $key_type
<span
class="initializer"> = IntlPartsIterator::KEY_SEQUENTIAL
] )
public string getText ( <span class="methodparam">void )
public bool
isBoundary ( <span
class="methodparam">int $offset
)
public int <span class="methodname">last ( void )
public int <span
class="methodname">next ([ <span
class="type">int $offset
] )
public int <span
class="methodname">preceding ( <span
class="type">int $offset
)
public int <span class="methodname">previous ( <span class="methodparam">void )
public bool
setText ( <span
class="methodparam">string $text
)
}
预定义常量
IntlBreakIterator::DONE
IntlBreakIterator::WORD_NONE
IntlBreakIterator::WORD_NONE_LIMIT
IntlBreakIterator::WORD_NUMBER
IntlBreakIterator::WORD_NUMBER_LIMIT
IntlBreakIterator::WORD_LETTER
IntlBreakIterator::WORD_LETTER_LIMIT
IntlBreakIterator::WORD_KANA
IntlBreakIterator::WORD_KANA_LIMIT
IntlBreakIterator::WORD_IDEO
IntlBreakIterator::WORD_IDEO_LIMIT
IntlBreakIterator::LINE_SOFT
IntlBreakIterator::LINE_SOFT_LIMIT
IntlBreakIterator::LINE_HARD
IntlBreakIterator::LINE_HARD_LIMIT
IntlBreakIterator::SENTENCE_TERM
IntlBreakIterator::SENTENCE_TERM_LIMIT
IntlBreakIterator::SENTENCE_SEP
IntlBreakIterator::SENTENCE_SEP_LIMIT
IntlBreakIterator::__construct
Private constructor for disallowing instantiation
说明
private <span class="methodname">IntlBreakIterator::__construct ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlBreakIterator::createCharacterInstance
Create break iterator for boundaries of combining character sequences
说明
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createCharacterInstance ([
string
$locale
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
locale
返回值
IntlBreakIterator::createCodePointInstance
Create break iterator for boundaries of code points
说明
public <span class="modifier">static <span class="type">IntlBreakIterator <span class="methodname">IntlBreakIterator::createCodePointInstance ( void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlBreakIterator::createLineInstance
Create break iterator for logically possible line breaks
说明
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createLineInstance ([
string
$locale
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
locale
返回值
IntlBreakIterator::createSentenceInstance
Create break iterator for sentence breaks
说明
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createSentenceInstance ([
string
$locale
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
locale
返回值
IntlBreakIterator::createTitleInstance
Create break iterator for title-casing breaks
说明
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createTitleInstance ([
string
$locale
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
locale
返回值
IntlBreakIterator::createWordInstance
Create break iterator for word breaks
说明
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createWordInstance ([
string
$locale
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
locale
返回值
IntlBreakIterator::current
Get index of current position
说明
public int <span class="methodname">IntlBreakIterator::current ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlBreakIterator::first
Set position to the first character in the text
说明
public int <span class="methodname">IntlBreakIterator::first ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlBreakIterator::following
Advance the iterator to the first boundary following specified offset
说明
public int <span
class="methodname">IntlBreakIterator::following ( <span
class="methodparam">int $offset
)
Warning
本函数还未编写文档,仅有参数列表。
参数
offset
返回值
IntlBreakIterator::getErrorCode
intl_get_error_code
Get last error code on the object
说明
面向对象风格 (method):
public int <span class="methodname">IntlBreakIterator::getErrorCode ( <span class="methodparam">void )
过程化风格:
int <span class="methodname">intl_get_error_code ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlBreakIterator::getErrorMessage
intl_get_error_message
Get last error message on the object
说明
面向对象风格 (method):
public string IntlBreakIterator::getErrorMessage ( void )
过程化风格:
string <span class="methodname">intl_get_error_message ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlBreakIterator::getLocale
Get the locale associated with the object
说明
public string
IntlBreakIterator::getLocale ( <span
class="methodparam">string
$locale_type
)
Warning
本函数还未编写文档,仅有参数列表。
参数
locale_type
返回值
IntlBreakIterator::getPartsIterator
Create iterator for navigating fragments between boundaries
说明
public <span
class="type">IntlPartsIterator <span
class="methodname">IntlBreakIterator::getPartsIterator ([ <span
class="methodparam">int $key_type
<span
class="initializer"> = IntlPartsIterator::KEY_SEQUENTIAL
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
key_type
Optional key type. Possible values are:
IntlPartsIterator::KEY_SEQUENTIAL
- The default. Sequentially increasing integers used as key.IntlPartsIterator::KEY_LEFT
- Byte offset left of current part used as key.IntlPartsIterator::KEY_RIGHT
- Byte offset right of current part used as key.
返回值
IntlBreakIterator::getText
Get the text being scanned
说明
public string IntlBreakIterator::getText ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlBreakIterator::isBoundary
Tell whether an offset is a boundaryʼs offset
说明
public bool
IntlBreakIterator::isBoundary ( <span
class="methodparam">int $offset
)
Warning
本函数还未编写文档,仅有参数列表。
参数
offset
返回值
IntlBreakIterator::last
Set the iterator position to index beyond the last character
说明
public int <span class="methodname">IntlBreakIterator::last ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlBreakIterator::next
Advance the iterator the next boundary
说明
public int <span
class="methodname">IntlBreakIterator::next ([ <span
class="methodparam">int $offset
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
offset
返回值
IntlBreakIterator::preceding
Set the iterator position to the first boundary before an offset
说明
public int <span
class="methodname">IntlBreakIterator::preceding ( <span
class="methodparam">int $offset
)
Warning
本函数还未编写文档,仅有参数列表。
参数
offset
返回值
IntlBreakIterator::previous
Set the iterator position to the boundary immediately before the current
说明
public int <span class="methodname">IntlBreakIterator::previous ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlBreakIterator::setText
Set the text being scanned
说明
public bool
IntlBreakIterator::setText ( <span
class="methodparam">string $text
)
Warning
本函数还未编写文档,仅有参数列表。
参数
text
返回值
简介
A subclass of IntlBreakIterator that encapsulates ICU break iterators whose behavior is specified using a set of rules. This is the most common kind of break iterators.
These rules are described in the » ICU Boundary Analysis User Guide.
类摘要
IntlRuleBasedBreakIterator
class IntlRuleBasedBreakIterator extends IntlBreakIterator implements <span class="interfacename">Traversable {
/* 继承的常量 */
const int
IntlBreakIterator::DONE
= -1 ;
const int
IntlBreakIterator::WORD_NONE
= 0 ;
const int
IntlBreakIterator::WORD_NONE_LIMIT
=
100 ;
const int
IntlBreakIterator::WORD_NUMBER
= 100
;
const int
IntlBreakIterator::WORD_NUMBER_LIMIT
=
200 ;
const int
IntlBreakIterator::WORD_LETTER
= 200
;
const int
IntlBreakIterator::WORD_LETTER_LIMIT
=
300 ;
const int
IntlBreakIterator::WORD_KANA
= 300 ;
const int
IntlBreakIterator::WORD_KANA_LIMIT
=
400 ;
const int
IntlBreakIterator::WORD_IDEO
= 400 ;
const int
IntlBreakIterator::WORD_IDEO_LIMIT
=
500 ;
const int
IntlBreakIterator::LINE_SOFT
= 0 ;
const int
IntlBreakIterator::LINE_SOFT_LIMIT
=
100 ;
const int
IntlBreakIterator::LINE_HARD
= 100 ;
const int
IntlBreakIterator::LINE_HARD_LIMIT
=
200 ;
const int
IntlBreakIterator::SENTENCE_TERM
= 0
;
const int
IntlBreakIterator::SENTENCE_TERM_LIMIT
=
100 ;
const int
IntlBreakIterator::SENTENCE_SEP
=
100 ;
const int
IntlBreakIterator::SENTENCE_SEP_LIMIT
=
200 ;
/* 方法 */
public <span
class="methodname">__construct ( <span
class="methodparam">string $rules
[,
string
$areCompiled
] )
public string getBinaryRules ( <span class="methodparam">void )
public string getRules ( <span class="methodparam">void )
public int <span class="methodname">getRuleStatus ( <span class="methodparam">void )
public array getRuleStatusVec ( <span class="methodparam">void )
/* 继承的方法 */
private <span class="methodname">IntlBreakIterator::__construct ( <span class="methodparam">void )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createCharacterInstance ([
string
$locale
] )
public <span class="modifier">static <span class="type">IntlBreakIterator <span class="methodname">IntlBreakIterator::createCodePointInstance ( void )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createLineInstance ([
string
$locale
] )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createSentenceInstance ([
string
$locale
] )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createTitleInstance ([
string
$locale
] )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createWordInstance ([
string
$locale
] )
public int <span class="methodname">IntlBreakIterator::current ( <span class="methodparam">void )
public int <span class="methodname">IntlBreakIterator::first ( <span class="methodparam">void )
public int <span
class="methodname">IntlBreakIterator::following ( <span
class="methodparam">int $offset
)
public int <span class="methodname">IntlBreakIterator::getErrorCode ( <span class="methodparam">void )
int <span class="methodname">intl_get_error_code ( <span class="methodparam">void )
public string IntlBreakIterator::getErrorMessage ( void )
string <span class="methodname">intl_get_error_message ( <span class="methodparam">void )
public string
IntlBreakIterator::getLocale ( <span
class="methodparam">string
$locale_type
)
public <span
class="type">IntlPartsIterator <span
class="methodname">IntlBreakIterator::getPartsIterator ([ <span
class="methodparam">int $key_type
<span
class="initializer"> = IntlPartsIterator::KEY_SEQUENTIAL
] )
public string IntlBreakIterator::getText ( <span class="methodparam">void )
public bool
IntlBreakIterator::isBoundary ( <span
class="methodparam">int $offset
)
public int <span class="methodname">IntlBreakIterator::last ( <span class="methodparam">void )
public int <span
class="methodname">IntlBreakIterator::next ([ <span
class="methodparam">int $offset
] )
public int <span
class="methodname">IntlBreakIterator::preceding ( <span
class="methodparam">int $offset
)
public int <span class="methodname">IntlBreakIterator::previous ( <span class="methodparam">void )
public bool
IntlBreakIterator::setText ( <span
class="methodparam">string $text
)
}
IntlRuleBasedBreakIterator::__construct
Create iterator from ruleset
说明
public <span
class="methodname">IntlRuleBasedBreakIterator::__construct (
string
$rules
[, <span
class="type">string $areCompiled
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
rules
areCompiled
返回值
IntlRuleBasedBreakIterator::getBinaryRules
Get the binary form of compiled rules
说明
public string <span class="methodname">IntlRuleBasedBreakIterator::getBinaryRules ( void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlRuleBasedBreakIterator::getRules
Get the rule set used to create this object
说明
public string IntlRuleBasedBreakIterator::getRules ( void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlRuleBasedBreakIterator::getRuleStatus
Get the largest status value from the break rules that determined the current break position
说明
public int <span class="methodname">IntlRuleBasedBreakIterator::getRuleStatus ( void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlRuleBasedBreakIterator::getRuleStatusVec
Get the status values from the break rules that determined the current break position
说明
public array <span class="methodname">IntlRuleBasedBreakIterator::getRuleStatusVec ( void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
简介
This break iterator identifies the boundaries between UTF-8 code points.
类摘要
IntlCodePointBreakIterator
class IntlCodePointBreakIterator extends IntlBreakIterator implements <span class="interfacename">Traversable {
/* 继承的常量 */
const int
IntlBreakIterator::DONE
= -1 ;
const int
IntlBreakIterator::WORD_NONE
= 0 ;
const int
IntlBreakIterator::WORD_NONE_LIMIT
=
100 ;
const int
IntlBreakIterator::WORD_NUMBER
= 100
;
const int
IntlBreakIterator::WORD_NUMBER_LIMIT
=
200 ;
const int
IntlBreakIterator::WORD_LETTER
= 200
;
const int
IntlBreakIterator::WORD_LETTER_LIMIT
=
300 ;
const int
IntlBreakIterator::WORD_KANA
= 300 ;
const int
IntlBreakIterator::WORD_KANA_LIMIT
=
400 ;
const int
IntlBreakIterator::WORD_IDEO
= 400 ;
const int
IntlBreakIterator::WORD_IDEO_LIMIT
=
500 ;
const int
IntlBreakIterator::LINE_SOFT
= 0 ;
const int
IntlBreakIterator::LINE_SOFT_LIMIT
=
100 ;
const int
IntlBreakIterator::LINE_HARD
= 100 ;
const int
IntlBreakIterator::LINE_HARD_LIMIT
=
200 ;
const int
IntlBreakIterator::SENTENCE_TERM
= 0
;
const int
IntlBreakIterator::SENTENCE_TERM_LIMIT
=
100 ;
const int
IntlBreakIterator::SENTENCE_SEP
=
100 ;
const int
IntlBreakIterator::SENTENCE_SEP_LIMIT
=
200 ;
/* 方法 */
public int <span class="methodname">getLastCodePoint ( <span class="methodparam">void )
/* 继承的方法 */
private <span class="methodname">IntlBreakIterator::__construct ( <span class="methodparam">void )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createCharacterInstance ([
string
$locale
] )
public <span class="modifier">static <span class="type">IntlBreakIterator <span class="methodname">IntlBreakIterator::createCodePointInstance ( void )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createLineInstance ([
string
$locale
] )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createSentenceInstance ([
string
$locale
] )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createTitleInstance ([
string
$locale
] )
public <span
class="modifier">static <span
class="type">IntlBreakIterator <span
class="methodname">IntlBreakIterator::createWordInstance ([
string
$locale
] )
public int <span class="methodname">IntlBreakIterator::current ( <span class="methodparam">void )
public int <span class="methodname">IntlBreakIterator::first ( <span class="methodparam">void )
public int <span
class="methodname">IntlBreakIterator::following ( <span
class="methodparam">int $offset
)
public int <span class="methodname">IntlBreakIterator::getErrorCode ( <span class="methodparam">void )
int <span class="methodname">intl_get_error_code ( <span class="methodparam">void )
public string IntlBreakIterator::getErrorMessage ( void )
string <span class="methodname">intl_get_error_message ( <span class="methodparam">void )
public string
IntlBreakIterator::getLocale ( <span
class="methodparam">string
$locale_type
)
public <span
class="type">IntlPartsIterator <span
class="methodname">IntlBreakIterator::getPartsIterator ([ <span
class="methodparam">int $key_type
<span
class="initializer"> = IntlPartsIterator::KEY_SEQUENTIAL
] )
public string IntlBreakIterator::getText ( <span class="methodparam">void )
public bool
IntlBreakIterator::isBoundary ( <span
class="methodparam">int $offset
)
public int <span class="methodname">IntlBreakIterator::last ( <span class="methodparam">void )
public int <span
class="methodname">IntlBreakIterator::next ([ <span
class="methodparam">int $offset
] )
public int <span
class="methodname">IntlBreakIterator::preceding ( <span
class="methodparam">int $offset
)
public int <span class="methodname">IntlBreakIterator::previous ( <span class="methodparam">void )
public bool
IntlBreakIterator::setText ( <span
class="methodparam">string $text
)
}
IntlCodePointBreakIterator::getLastCodePoint
Get last code point passed over after advancing or receding the iterator
说明
public int <span class="methodname">IntlCodePointBreakIterator::getLastCodePoint ( void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
简介
Objects of this class can be obtained from <span class="classname">IntlBreakIterator objects. While the break iterators provide a sequence of boundary positions when iterated, <span class="classname">IntlPartsIterator objects provide, as a convenience, the text fragments comprehended between two successive boundaries.
The keys may represent the offset of the left boundary, right boundary, or they may just the sequence of non-negative integers. See <span class="function">IntlBreakIterator::getPartsIterator.
类摘要
IntlPartsIterator
class IntlPartsIterator <span class="ooclass"> extends IntlIterator implements <span class="interfacename">Iterator {
/* Constants */
const int
IntlPartsIterator::KEY_SEQUENTIAL
=
0 ;
const int
IntlPartsIterator::KEY_LEFT
= 1 ;
const int
IntlPartsIterator::KEY_RIGHT
= 2 ;
/* 方法 */
public <span class="type">IntlBreakIterator <span class="methodname">getBreakIterator ( <span class="methodparam">void )
/* 继承的方法 */
public mixed IntlIterator::current ( <span class="methodparam">void )
public string IntlIterator::key ( <span class="methodparam">void )
public void IntlIterator::next ( <span class="methodparam">void )
public void IntlIterator::rewind ( <span class="methodparam">void )
public bool IntlIterator::valid ( <span class="methodparam">void )
}
预定义常量
IntlPartsIterator::KEY_SEQUENTIAL
IntlPartsIterator::KEY_LEFT
IntlPartsIterator::KEY_RIGHT
IntlPartsIterator::getBreakIterator
Get IntlBreakIterator backing this parts iterator
说明
public <span class="type">IntlBreakIterator <span class="methodname">IntlPartsIterator::getBreakIterator ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
简介
类摘要
UConverter
class UConverter {
/* Constants */
const int
UConverter::REASON_UNASSIGNED
= 0 ;
const int
UConverter::REASON_ILLEGAL
= 1 ;
const int
UConverter::REASON_IRREGULAR
= 2 ;
const int
UConverter::REASON_RESET
= 3 ;
const int
UConverter::REASON_CLOSE
= 4 ;
const int
UConverter::REASON_CLONE
= 5 ;
const int
UConverter::UNSUPPORTED_CONVERTER
=
-1 ;
const int
UConverter::SBCS
= 0 ;
const int
UConverter::DBCS
= 1 ;
const int
UConverter::MBCS
= 2 ;
const int
UConverter::LATIN_1
= 3 ;
const int
UConverter::UTF8
= 4 ;
const int
UConverter::UTF16_BigEndian
= 5 ;
const int
UConverter::UTF16_LittleEndian
= 6 ;
const int
UConverter::UTF32_BigEndian
= 7 ;
const int
UConverter::UTF32_LittleEndian
= 8 ;
const int
UConverter::EBCDIC_STATEFUL
= 9 ;
const int
UConverter::ISO_2022
= 10 ;
const int
UConverter::LMBCS_1
= 11 ;
const int
UConverter::LMBCS_2
= 12 ;
const int
UConverter::LMBCS_3
= 13 ;
const int
UConverter::LMBCS_4
= 14 ;
const int
UConverter::LMBCS_5
= 15 ;
const int
UConverter::LMBCS_6
= 16 ;
const int
UConverter::LMBCS_8
= 17 ;
const int
UConverter::LMBCS_11
= 18 ;
const int
UConverter::LMBCS_16
= 19 ;
const int
UConverter::LMBCS_17
= 20 ;
const int
UConverter::LMBCS_18
= 21 ;
const int
UConverter::LMBCS_19
= 22 ;
const int
UConverter::LMBCS_LAST
= 22 ;
const int
UConverter::HZ
= 23 ;
const int
UConverter::SCSU
= 24 ;
const int
UConverter::ISCII
= 25 ;
const int
UConverter::US_ASCII
= 26 ;
const int
UConverter::UTF7
= 27 ;
const int
UConverter::BOCU1
= 28 ;
const int
UConverter::UTF16
= 29 ;
const int
UConverter::UTF32
= 30 ;
const int
UConverter::CESU8
= 31 ;
const int
UConverter::IMAP_MAILBOX
= 32 ;
/* 方法 */
public <span
class="methodname">__construct ([ <span
class="methodparam">string
$destination_encoding
[, <span
class="type">string $source_encoding
]] )
public string
convert ( <span
class="methodparam">string $str
[,
bool
$reverse
] )
public mixed
fromUCallback ( <span
class="methodparam">int $reason
,
string
$source
, <span
class="type">string $codePoint
, <span
class="methodparam">int &$error
)
public <span
class="modifier">static array <span
class="methodname">getAliases ( <span
class="type">string $name
)
public <span class="modifier">static array <span class="methodname">getAvailable ( <span class="methodparam">void )
public string getDestinationEncoding ( <span class="methodparam">void )
public int <span class="methodname">getDestinationType ( <span class="methodparam">void )
public int <span class="methodname">getErrorCode ( <span class="methodparam">void )
public string getErrorMessage ( <span class="methodparam">void )
public string getSourceEncoding ( <span class="methodparam">void )
public int <span class="methodname">getSourceType ( <span class="methodparam">void )
public <span class="modifier">static array <span class="methodname">getStandards ( <span class="methodparam">void )
public string getSubstChars ( <span class="methodparam">void )
public <span
class="modifier">static string <span
class="methodname">reasonText ([ <span
class="type">int $reason
] )
public void
setDestinationEncoding ( <span
class="methodparam">string $encoding
)
public void
setSourceEncoding ( <span
class="methodparam">string $encoding
)
public void
setSubstChars ( <span
class="methodparam">string $chars
)
public mixed
toUCallback ( <span
class="methodparam">int $reason
,
string
$source
, <span
class="type">string $codeUnits
, <span
class="methodparam">int &$error
)
public <span
class="modifier">static string <span
class="methodname">transcode ( <span
class="type">string $str
, <span
class="methodparam">string
$toEncoding
, <span
class="type">string $fromEncoding
[, <span
class="methodparam">array $options
]
)
}
预定义常量
UConverter::REASON_UNASSIGNED
UConverter::REASON_ILLEGAL
UConverter::REASON_IRREGULAR
UConverter::REASON_RESET
UConverter::REASON_CLOSE
UConverter::REASON_CLONE
UConverter::UNSUPPORTED_CONVERTER
UConverter::SBCS
UConverter::DBCS
UConverter::MBCS
UConverter::LATIN_1
UConverter::UTF8
UConverter::UTF16_BigEndian
UConverter::UTF16_LittleEndian
UConverter::UTF32_BigEndian
UConverter::UTF32_LittleEndian
UConverter::EBCDIC_STATEFUL
UConverter::ISO_2022
UConverter::LMBCS_1
UConverter::LMBCS_2
UConverter::LMBCS_3
UConverter::LMBCS_4
UConverter::LMBCS_5
UConverter::LMBCS_6
UConverter::LMBCS_8
UConverter::LMBCS_11
UConverter::LMBCS_16
UConverter::LMBCS_17
UConverter::LMBCS_18
UConverter::LMBCS_19
UConverter::LMBCS_LAST
UConverter::HZ
UConverter::SCSU
UConverter::ISCII
UConverter::US_ASCII
UConverter::UTF7
UConverter::BOCU1
UConverter::UTF16
UConverter::UTF32
UConverter::CESU8
UConverter::IMAP_MAILBOX
UConverter::__construct
Create UConverter object
说明
public <span
class="methodname">UConverter::__construct ([ <span
class="methodparam">string
$destination_encoding
[, <span
class="type">string $source_encoding
]] )
Warning
本函数还未编写文档,仅有参数列表。
参数
destination_encoding
source_encoding
返回值
UConverter::convert
Convert string from one charset to another
说明
public string
UConverter::convert ( <span
class="methodparam">string $str
[,
bool
$reverse
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
str
reverse
返回值
UConverter::fromUCallback
Default "from" callback function
说明
public mixed
UConverter::fromUCallback ( <span
class="methodparam">int $reason
,
string
$source
, <span
class="type">string $codePoint
, <span
class="methodparam">int &$error
)
Warning
本函数还未编写文档,仅有参数列表。
参数
reason
source
codePoint
error
返回值
UConverter::getAliases
Get the aliases of the given name
说明
public <span
class="modifier">static array <span
class="methodname">UConverter::getAliases ( <span
class="methodparam">string $name
)
Warning
本函数还未编写文档,仅有参数列表。
参数
name
返回值
UConverter::getAvailable
Get the available canonical converter names
说明
public <span class="modifier">static array <span class="methodname">UConverter::getAvailable ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
UConverter::getDestinationEncoding
Get the destination encoding
说明
public string UConverter::getDestinationEncoding ( void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
UConverter::getDestinationType
Get the destination converter type
说明
public int <span class="methodname">UConverter::getDestinationType ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
UConverter::getErrorCode
intl_get_error_code
Get last error code on the object
说明
public int <span class="methodname">UConverter::getErrorCode ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
UConverter::getErrorMessage
Get last error message on the object
说明
public string UConverter::getErrorMessage ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
UConverter::getSourceEncoding
Get the source encoding
说明
public string UConverter::getSourceEncoding ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
UConverter::getSourceType
Get the source converter type
说明
public int <span class="methodname">UConverter::getSourceType ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
UConverter::getStandards
Get standards associated to converter names
说明
public <span class="modifier">static array <span class="methodname">UConverter::getStandards ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
UConverter::getSubstChars
Get substitution chars
说明
public string UConverter::getSubstChars ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
UConverter::reasonText
Get string representation of the callback reason
说明
public <span
class="modifier">static string <span
class="methodname">UConverter::reasonText ([ <span
class="methodparam">int $reason
] )
Warning
本函数还未编写文档,仅有参数列表。
参数
reason
返回值
UConverter::setDestinationEncoding
Set the destination encoding
说明
public void
UConverter::setDestinationEncoding (
string
$encoding
)
Warning
本函数还未编写文档,仅有参数列表。
参数
encoding
返回值
UConverter::setSourceEncoding
Set the source encoding
说明
public void
UConverter::setSourceEncoding ( <span
class="methodparam">string $encoding
)
Warning
本函数还未编写文档,仅有参数列表。
参数
encoding
返回值
UConverter::setSubstChars
Set the substitution chars
说明
public void
UConverter::setSubstChars ( <span
class="methodparam">string $chars
)
Warning
本函数还未编写文档,仅有参数列表。
参数
chars
返回值
UConverter::toUCallback
Default "to" callback function
说明
public mixed
UConverter::toUCallback ( <span
class="methodparam">int $reason
,
string
$source
, <span
class="type">string $codeUnits
, <span
class="methodparam">int &$error
)
Warning
本函数还未编写文档,仅有参数列表。
参数
reason
source
codeUnits
error
返回值
UConverter::transcode
Convert string from one charset to another
说明
public <span
class="modifier">static string <span
class="methodname">UConverter::transcode ( <span
class="methodparam">string $str
,
string
$toEncoding
, <span
class="type">string $fromEncoding
[, <span
class="methodparam">array $options
]
)
Warning
本函数还未编写文档,仅有参数列表。
参数
str
toEncoding
fromEncoding
options
返回值
简介
IntlChar provides access to a number of utility methods that can be used to access information about Unicode characters.
The methods and constants adhere closely to the names and behavior used by the underlying ICU library.
类摘要
IntlChar
class IntlChar {
/* Constants */
const string
IntlChar::UNICODE_VERSION
= 6.3 ;
const int
IntlChar::CODEPOINT_MIN
= 0 ;
const int
IntlChar::CODEPOINT_MAX
= 1114111 ;
const float
IntlChar::NO_NUMERIC_VALUE
=
-123456789 ;
const int
IntlChar::PROPERTY_ALPHABETIC
= 0 ;
const int
IntlChar::PROPERTY_BINARY_START
= 0
;
const int
IntlChar::PROPERTY_ASCII_HEX_DIGIT
=
1 ;
const int
IntlChar::PROPERTY_BIDI_CONTROL
= 2
;
const int
IntlChar::PROPERTY_BIDI_MIRRORED
= 3
;
const int
IntlChar::PROPERTY_DASH
= 4 ;
const int
IntlChar::PROPERTY_DEFAULT_IGNORABLE_CODE_POINT
<span
class="initializer"> = 5 ;
const int
IntlChar::PROPERTY_DEPRECATED
= 6 ;
const int
IntlChar::PROPERTY_DIACRITIC
= 7 ;
const int
IntlChar::PROPERTY_EXTENDER
= 8 ;
const int
IntlChar::PROPERTY_FULL_COMPOSITION_EXCLUSION
<span
class="initializer"> = 9 ;
const int
IntlChar::PROPERTY_GRAPHEME_BASE
=
10 ;
const int
IntlChar::PROPERTY_GRAPHEME_EXTEND
=
11 ;
const int
IntlChar::PROPERTY_GRAPHEME_LINK
=
12 ;
const int
IntlChar::PROPERTY_HEX_DIGIT
= 13 ;
const int
IntlChar::PROPERTY_HYPHEN
= 14 ;
const int
IntlChar::PROPERTY_ID_CONTINUE
= 15
;
const int
IntlChar::PROPERTY_ID_START
= 16 ;
const int
IntlChar::PROPERTY_IDEOGRAPHIC
= 17
;
const int
IntlChar::PROPERTY_IDS_BINARY_OPERATOR
=
18 ;
const int
IntlChar::PROPERTY_IDS_TRINARY_OPERATOR
=
19 ;
const int
IntlChar::PROPERTY_JOIN_CONTROL
= 20
;
const int
IntlChar::PROPERTY_LOGICAL_ORDER_EXCEPTION
= 21 ;
const int
IntlChar::PROPERTY_LOWERCASE
= 22 ;
const int
IntlChar::PROPERTY_MATH
= 23 ;
const int
IntlChar::PROPERTY_NONCHARACTER_CODE_POINT
= 24 ;
const int
IntlChar::PROPERTY_QUOTATION_MARK
=
25 ;
const int
IntlChar::PROPERTY_RADICAL
= 26 ;
const int
IntlChar::PROPERTY_SOFT_DOTTED
= 27
;
const int
IntlChar::PROPERTY_TERMINAL_PUNCTUATION
=
28 ;
const int
IntlChar::PROPERTY_UNIFIED_IDEOGRAPH
=
29 ;
const int
IntlChar::PROPERTY_UPPERCASE
= 30 ;
const int
IntlChar::PROPERTY_WHITE_SPACE
= 31
;
const int
IntlChar::PROPERTY_XID_CONTINUE
= 32
;
const int
IntlChar::PROPERTY_XID_START
= 33 ;
const int
IntlChar::PROPERTY_CASE_SENSITIVE
=
34 ;
const int
IntlChar::PROPERTY_S_TERM
= 35 ;
const int
IntlChar::PROPERTY_VARIATION_SELECTOR
=
36 ;
const int
IntlChar::PROPERTY_NFD_INERT
= 37 ;
const int
IntlChar::PROPERTY_NFKD_INERT
= 38 ;
const int
IntlChar::PROPERTY_NFC_INERT
= 39 ;
const int
IntlChar::PROPERTY_NFKC_INERT
= 40 ;
const int
IntlChar::PROPERTY_SEGMENT_STARTER
=
41 ;
const int
IntlChar::PROPERTY_PATTERN_SYNTAX
=
42 ;
const int
IntlChar::PROPERTY_PATTERN_WHITE_SPACE
=
43 ;
const int
IntlChar::PROPERTY_POSIX_ALNUM
= 44
;
const int
IntlChar::PROPERTY_POSIX_BLANK
= 45
;
const int
IntlChar::PROPERTY_POSIX_GRAPH
= 46
;
const int
IntlChar::PROPERTY_POSIX_PRINT
= 47
;
const int
IntlChar::PROPERTY_POSIX_XDIGIT
= 48
;
const int
IntlChar::PROPERTY_CASED
= 49 ;
const int
IntlChar::PROPERTY_CASE_IGNORABLE
=
50 ;
const int
IntlChar::PROPERTY_CHANGES_WHEN_LOWERCASED
= 51 ;
const int
IntlChar::PROPERTY_CHANGES_WHEN_UPPERCASED
= 52 ;
const int
IntlChar::PROPERTY_CHANGES_WHEN_TITLECASED
= 53 ;
const int
IntlChar::PROPERTY_CHANGES_WHEN_CASEFOLDED
= 54 ;
const int
IntlChar::PROPERTY_CHANGES_WHEN_CASEMAPPED
= 55 ;
const int
IntlChar::PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED
<span
class="initializer"> = 56 ;
const int
IntlChar::PROPERTY_BINARY_LIMIT
= 57
;
const int
IntlChar::PROPERTY_BIDI_CLASS
= 4096
;
const int
IntlChar::PROPERTY_INT_START
= 4096
;
const int
IntlChar::PROPERTY_BLOCK
= 4097 ;
const int
IntlChar::PROPERTY_CANONICAL_COMBINING_CLASS
<span
class="initializer"> = 4098 ;
const int
IntlChar::PROPERTY_DECOMPOSITION_TYPE
=
4099 ;
const int
IntlChar::PROPERTY_EAST_ASIAN_WIDTH
=
4100 ;
const int
IntlChar::PROPERTY_GENERAL_CATEGORY
=
4101 ;
const int
IntlChar::PROPERTY_JOINING_GROUP
=
4102 ;
const int
IntlChar::PROPERTY_JOINING_TYPE
=
4103 ;
const int
IntlChar::PROPERTY_LINE_BREAK
= 4104
;
const int
IntlChar::PROPERTY_NUMERIC_TYPE
=
4105 ;
const int
IntlChar::PROPERTY_SCRIPT
= 4106 ;
const int
IntlChar::PROPERTY_HANGUL_SYLLABLE_TYPE
=
4107 ;
const int
IntlChar::PROPERTY_NFD_QUICK_CHECK
=
4108 ;
const int
IntlChar::PROPERTY_NFKD_QUICK_CHECK
=
4109 ;
const int
IntlChar::PROPERTY_NFC_QUICK_CHECK
=
4110 ;
const int
IntlChar::PROPERTY_NFKC_QUICK_CHECK
=
4111 ;
const int
IntlChar::PROPERTY_LEAD_CANONICAL_COMBINING_CLASS
<span
class="initializer"> = 4112 ;
const int
IntlChar::PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS
<span
class="initializer"> = 4113 ;
const int
IntlChar::PROPERTY_GRAPHEME_CLUSTER_BREAK
=
4114 ;
const int
IntlChar::PROPERTY_SENTENCE_BREAK
=
4115 ;
const int
IntlChar::PROPERTY_WORD_BREAK
= 4116
;
const int
IntlChar::PROPERTY_BIDI_PAIRED_BRACKET_TYPE
= 4117 ;
const int
IntlChar::PROPERTY_INT_LIMIT
= 4118
;
const int
IntlChar::PROPERTY_GENERAL_CATEGORY_MASK
=
8192 ;
const int
IntlChar::PROPERTY_MASK_START
= 8192
;
const int
IntlChar::PROPERTY_MASK_LIMIT
= 8193
;
const int
IntlChar::PROPERTY_NUMERIC_VALUE
=
12288 ;
const int
IntlChar::PROPERTY_DOUBLE_START
=
12288 ;
const int
IntlChar::PROPERTY_DOUBLE_LIMIT
=
12289 ;
const int
IntlChar::PROPERTY_AGE
= 16384 ;
const int
IntlChar::PROPERTY_STRING_START
=
16384 ;
const int
IntlChar::PROPERTY_BIDI_MIRRORING_GLYPH
=
16385 ;
const int
IntlChar::PROPERTY_CASE_FOLDING
=
16386 ;
const int
IntlChar::PROPERTY_ISO_COMMENT
=
16387 ;
const int
IntlChar::PROPERTY_LOWERCASE_MAPPING
=
16388 ;
const int
IntlChar::PROPERTY_NAME
= 16389 ;
const int
IntlChar::PROPERTY_SIMPLE_CASE_FOLDING
=
16390 ;
const int
IntlChar::PROPERTY_SIMPLE_LOWERCASE_MAPPING
= 16391 ;
const int
IntlChar::PROPERTY_SIMPLE_TITLECASE_MAPPING
= 16392 ;
const int
IntlChar::PROPERTY_SIMPLE_UPPERCASE_MAPPING
= 16393 ;
const int
IntlChar::PROPERTY_TITLECASE_MAPPING
=
16394 ;
const int
IntlChar::PROPERTY_UNICODE_1_NAME
=
16395 ;
const int
IntlChar::PROPERTY_UPPERCASE_MAPPING
=
16396 ;
const int
IntlChar::PROPERTY_BIDI_PAIRED_BRACKET
=
16397 ;
const int
IntlChar::PROPERTY_STRING_LIMIT
=
16398 ;
const int
IntlChar::PROPERTY_SCRIPT_EXTENSIONS
=
28672 ;
const int
IntlChar::PROPERTY_OTHER_PROPERTY_START
=
28672 ;
const int
IntlChar::PROPERTY_OTHER_PROPERTY_LIMIT
=
28673 ;
const int
IntlChar::PROPERTY_INVALID_CODE
= -1
;
const int
IntlChar::CHAR_CATEGORY_UNASSIGNED
=
0 ;
const int
IntlChar::CHAR_CATEGORY_GENERAL_OTHER_TYPES
= 0 ;
const int
IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER
=
1 ;
const int
IntlChar::CHAR_CATEGORY_LOWERCASE_LETTER
=
2 ;
const int
IntlChar::CHAR_CATEGORY_TITLECASE_LETTER
=
3 ;
const int
IntlChar::CHAR_CATEGORY_MODIFIER_LETTER
=
4 ;
const int
IntlChar::CHAR_CATEGORY_OTHER_LETTER
=
5 ;
const int
IntlChar::CHAR_CATEGORY_NON_SPACING_MARK
=
6 ;
const int
IntlChar::CHAR_CATEGORY_ENCLOSING_MARK
=
7 ;
const int
IntlChar::CHAR_CATEGORY_COMBINING_SPACING_MARK
<span
class="initializer"> = 8 ;
const int
IntlChar::CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER
<span
class="initializer"> = 9 ;
const int
IntlChar::CHAR_CATEGORY_LETTER_NUMBER
=
10 ;
const int
IntlChar::CHAR_CATEGORY_OTHER_NUMBER
=
11 ;
const int
IntlChar::CHAR_CATEGORY_SPACE_SEPARATOR
=
12 ;
const int
IntlChar::CHAR_CATEGORY_LINE_SEPARATOR
=
13 ;
const int
IntlChar::CHAR_CATEGORY_PARAGRAPH_SEPARATOR
= 14 ;
const int
IntlChar::CHAR_CATEGORY_CONTROL_CHAR
=
15 ;
const int
IntlChar::CHAR_CATEGORY_FORMAT_CHAR
=
16 ;
const int
IntlChar::CHAR_CATEGORY_PRIVATE_USE_CHAR
=
17 ;
const int
IntlChar::CHAR_CATEGORY_SURROGATE
=
18 ;
const int
IntlChar::CHAR_CATEGORY_DASH_PUNCTUATION
=
19 ;
const int
IntlChar::CHAR_CATEGORY_START_PUNCTUATION
=
20 ;
const int
IntlChar::CHAR_CATEGORY_END_PUNCTUATION
=
21 ;
const int
IntlChar::CHAR_CATEGORY_CONNECTOR_PUNCTUATION
<span
class="initializer"> = 22 ;
const int
IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION
=
23 ;
const int
IntlChar::CHAR_CATEGORY_MATH_SYMBOL
=
24 ;
const int
IntlChar::CHAR_CATEGORY_CURRENCY_SYMBOL
=
25 ;
const int
IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL
=
26 ;
const int
IntlChar::CHAR_CATEGORY_OTHER_SYMBOL
=
27 ;
const int
IntlChar::CHAR_CATEGORY_INITIAL_PUNCTUATION
= 28 ;
const int
IntlChar::CHAR_CATEGORY_FINAL_PUNCTUATION
=
29 ;
const int
IntlChar::CHAR_CATEGORY_CHAR_CATEGORY_COUNT
= 30 ;
const int
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT
=
0 ;
const int
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT
=
1 ;
const int
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER
=
2 ;
const int
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR
<span
class="initializer"> = 3 ;
const int
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR
<span
class="initializer"> = 4 ;
const int
IntlChar::CHAR_DIRECTION_ARABIC_NUMBER
=
5 ;
const int
IntlChar::CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR
<span
class="initializer"> = 6 ;
const int
IntlChar::CHAR_DIRECTION_BLOCK_SEPARATOR
=
7 ;
const int
IntlChar::CHAR_DIRECTION_SEGMENT_SEPARATOR
= 8 ;
const int
IntlChar::CHAR_DIRECTION_WHITE_SPACE_NEUTRAL
<span
class="initializer"> = 9 ;
const int
IntlChar::CHAR_DIRECTION_OTHER_NEUTRAL
=
10 ;
const int
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING
<span
class="initializer"> = 11 ;
const int
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE
<span
class="initializer"> = 12 ;
const int
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC
<span
class="initializer"> = 13 ;
const int
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING
<span
class="initializer"> = 14 ;
const int
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE
<span
class="initializer"> = 15 ;
const int
IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT
<span
class="initializer"> = 16 ;
const int
IntlChar::CHAR_DIRECTION_DIR_NON_SPACING_MARK
<span
class="initializer"> = 17 ;
const int
IntlChar::CHAR_DIRECTION_BOUNDARY_NEUTRAL
=
18 ;
const int
IntlChar::CHAR_DIRECTION_FIRST_STRONG_ISOLATE
<span
class="initializer"> = 19 ;
const int
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE
<span
class="initializer"> = 20 ;
const int
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE
<span
class="initializer"> = 21 ;
const int
IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE
<span
class="initializer"> = 22 ;
const int
IntlChar::CHAR_DIRECTION_CHAR_DIRECTION_COUNT
<span
class="initializer"> = 23 ;
const int
IntlChar::BLOCK_CODE_NO_BLOCK
= 0 ;
const int
IntlChar::BLOCK_CODE_BASIC_LATIN
= 1
;
const int
IntlChar::BLOCK_CODE_LATIN_1_SUPPLEMENT
=
2 ;
const int
IntlChar::BLOCK_CODE_LATIN_EXTENDED_A
=
3 ;
const int
IntlChar::BLOCK_CODE_LATIN_EXTENDED_B
=
4 ;
const int
IntlChar::BLOCK_CODE_IPA_EXTENSIONS
=
5 ;
const int
IntlChar::BLOCK_CODE_SPACING_MODIFIER_LETTERS
<span
class="initializer"> = 6 ;
const int
IntlChar::BLOCK_CODE_COMBINING_DIACRITICAL_MARKS
<span
class="initializer"> = 7 ;
const int
IntlChar::BLOCK_CODE_GREEK
= 8 ;
const int
IntlChar::BLOCK_CODE_CYRILLIC
= 9 ;
const int
IntlChar::BLOCK_CODE_ARMENIAN
= 10 ;
const int
IntlChar::BLOCK_CODE_HEBREW
= 11 ;
const int
IntlChar::BLOCK_CODE_ARABIC
= 12 ;
const int
IntlChar::BLOCK_CODE_SYRIAC
= 13 ;
const int
IntlChar::BLOCK_CODE_THAANA
= 14 ;
const int
IntlChar::BLOCK_CODE_DEVANAGARI
= 15
;
const int
IntlChar::BLOCK_CODE_BENGALI
= 16 ;
const int
IntlChar::BLOCK_CODE_GURMUKHI
= 17 ;
const int
IntlChar::BLOCK_CODE_GUJARATI
= 18 ;
const int
IntlChar::BLOCK_CODE_ORIYA
= 19 ;
const int
IntlChar::BLOCK_CODE_TAMIL
= 20 ;
const int
IntlChar::BLOCK_CODE_TELUGU
= 21 ;
const int
IntlChar::BLOCK_CODE_KANNADA
= 22 ;
const int
IntlChar::BLOCK_CODE_MALAYALAM
= 23
;
const int
IntlChar::BLOCK_CODE_SINHALA
= 24 ;
const int
IntlChar::BLOCK_CODE_THAI
= 25 ;
const int
IntlChar::BLOCK_CODE_LAO
= 26 ;
const int
IntlChar::BLOCK_CODE_TIBETAN
= 27 ;
const int
IntlChar::BLOCK_CODE_MYANMAR
= 28 ;
const int
IntlChar::BLOCK_CODE_GEORGIAN
= 29 ;
const int
IntlChar::BLOCK_CODE_HANGUL_JAMO
=
30 ;
const int
IntlChar::BLOCK_CODE_ETHIOPIC
= 31 ;
const int
IntlChar::BLOCK_CODE_CHEROKEE
= 32 ;
const int
IntlChar::BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS
<span
class="initializer"> = 33 ;
const int
IntlChar::BLOCK_CODE_OGHAM
= 34 ;
const int
IntlChar::BLOCK_CODE_RUNIC
= 35 ;
const int
IntlChar::BLOCK_CODE_KHMER
= 36 ;
const int
IntlChar::BLOCK_CODE_MONGOLIAN
= 37
;
const int
IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL
<span
class="initializer"> = 38 ;
const int
IntlChar::BLOCK_CODE_GREEK_EXTENDED
=
39 ;
const int
IntlChar::BLOCK_CODE_GENERAL_PUNCTUATION
=
40 ;
const int
IntlChar::BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS
<span
class="initializer"> = 41 ;
const int
IntlChar::BLOCK_CODE_CURRENCY_SYMBOLS
=
42 ;
const int
IntlChar::BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS
<span
class="initializer"> = 43 ;
const int
IntlChar::BLOCK_CODE_LETTERLIKE_SYMBOLS
=
44 ;
const int
IntlChar::BLOCK_CODE_NUMBER_FORMS
=
45 ;
const int
IntlChar::BLOCK_CODE_ARROWS
= 46 ;
const int
IntlChar::BLOCK_CODE_MATHEMATICAL_OPERATORS
= 47 ;
const int
IntlChar::BLOCK_CODE_MISCELLANEOUS_TECHNICAL
<span
class="initializer"> = 48 ;
const int
IntlChar::BLOCK_CODE_CONTROL_PICTURES
=
49 ;
const int
IntlChar::BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION
<span
class="initializer"> = 50 ;
const int
IntlChar::BLOCK_CODE_ENCLOSED_ALPHANUMERICS
= 51 ;
const int
IntlChar::BLOCK_CODE_BOX_DRAWING
=
52 ;
const int
IntlChar::BLOCK_CODE_BLOCK_ELEMENTS
=
53 ;
const int
IntlChar::BLOCK_CODE_GEOMETRIC_SHAPES
=
54 ;
const int
IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS
= 55 ;
const int
IntlChar::BLOCK_CODE_DINGBATS
= 56 ;
const int
IntlChar::BLOCK_CODE_BRAILLE_PATTERNS
=
57 ;
const int
IntlChar::BLOCK_CODE_CJK_RADICALS_SUPPLEMENT
<span
class="initializer"> = 58 ;
const int
IntlChar::BLOCK_CODE_KANGXI_RADICALS
=
59 ;
const int
IntlChar::BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS
<span
class="initializer"> = 60 ;
const int
IntlChar::BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION
<span
class="initializer"> = 61 ;
const int
IntlChar::BLOCK_CODE_HIRAGANA
= 62 ;
const int
IntlChar::BLOCK_CODE_KATAKANA
= 63 ;
const int
IntlChar::BLOCK_CODE_BOPOMOFO
= 64 ;
const int
IntlChar::BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO
<span
class="initializer"> = 65 ;
const int
IntlChar::BLOCK_CODE_KANBUN
= 66 ;
const int
IntlChar::BLOCK_CODE_BOPOMOFO_EXTENDED
=
67 ;
const int
IntlChar::BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS
<span
class="initializer"> = 68 ;
const int
IntlChar::BLOCK_CODE_CJK_COMPATIBILITY
=
69 ;
const int
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
<span
class="initializer"> = 70 ;
const int
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS
= 71 ;
const int
IntlChar::BLOCK_CODE_YI_SYLLABLES
=
72 ;
const int
IntlChar::BLOCK_CODE_YI_RADICALS
=
73 ;
const int
IntlChar::BLOCK_CODE_HANGUL_SYLLABLES
=
74 ;
const int
IntlChar::BLOCK_CODE_HIGH_SURROGATES
=
75 ;
const int
IntlChar::BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES
<span
class="initializer"> = 76 ;
const int
IntlChar::BLOCK_CODE_LOW_SURROGATES
=
77 ;
const int
IntlChar::BLOCK_CODE_PRIVATE_USE_AREA
=
78 ;
const int
IntlChar::BLOCK_CODE_PRIVATE_USE
=
78 ;
const int
IntlChar::BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS
<span
class="initializer"> = 79 ;
const int
IntlChar::BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS
<span
class="initializer"> = 80 ;
const int
IntlChar::BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A
<span
class="initializer"> = 81 ;
const int
IntlChar::BLOCK_CODE_COMBINING_HALF_MARKS
=
82 ;
const int
IntlChar::BLOCK_CODE_CJK_COMPATIBILITY_FORMS
<span
class="initializer"> = 83 ;
const int
IntlChar::BLOCK_CODE_SMALL_FORM_VARIANTS
=
84 ;
const int
IntlChar::BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B
<span
class="initializer"> = 85 ;
const int
IntlChar::BLOCK_CODE_SPECIALS
= 86 ;
const int
IntlChar::BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS
<span
class="initializer"> = 87 ;
const int
IntlChar::BLOCK_CODE_OLD_ITALIC
= 88
;
const int
IntlChar::BLOCK_CODE_GOTHIC
= 89 ;
const int
IntlChar::BLOCK_CODE_DESERET
= 90 ;
const int
IntlChar::BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS
<span
class="initializer"> = 91 ;
const int
IntlChar::BLOCK_CODE_MUSICAL_SYMBOLS
=
92 ;
const int
IntlChar::BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS
<span
class="initializer"> = 93 ;
const int
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
<span
class="initializer"> = 94 ;
const int
IntlChar::BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT
<span
class="initializer"> = 95 ;
const int
IntlChar::BLOCK_CODE_TAGS
= 96 ;
const int
IntlChar::BLOCK_CODE_CYRILLIC_SUPPLEMENT
=
97 ;
const int
IntlChar::BLOCK_CODE_CYRILLIC_SUPPLEMENTARY
= 97 ;
const int
IntlChar::BLOCK_CODE_TAGALOG
= 98 ;
const int
IntlChar::BLOCK_CODE_HANUNOO
= 99 ;
const int
IntlChar::BLOCK_CODE_BUHID
= 100 ;
const int
IntlChar::BLOCK_CODE_TAGBANWA
= 101
;
const int
IntlChar::BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A
<span
class="initializer"> = 102 ;
const int
IntlChar::BLOCK_CODE_SUPPLEMENTAL_ARROWS_A
= 103 ;
const int
IntlChar::BLOCK_CODE_SUPPLEMENTAL_ARROWS_B
= 104 ;
const int
IntlChar::BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B
<span
class="initializer"> = 105 ;
const int
IntlChar::BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS
<span
class="initializer"> = 106 ;
const int
IntlChar::BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS
<span
class="initializer"> = 107 ;
const int
IntlChar::BLOCK_CODE_VARIATION_SELECTORS
=
108 ;
const int
IntlChar::BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A
<span
class="initializer"> = 109 ;
const int
IntlChar::BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B
<span
class="initializer"> = 110 ;
const int
IntlChar::BLOCK_CODE_LIMBU
= 111 ;
const int
IntlChar::BLOCK_CODE_TAI_LE
= 112 ;
const int
IntlChar::BLOCK_CODE_KHMER_SYMBOLS
=
113 ;
const int
IntlChar::BLOCK_CODE_PHONETIC_EXTENSIONS
=
114 ;
const int
IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS
<span
class="initializer"> = 115 ;
const int
IntlChar::BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS
<span
class="initializer"> = 116 ;
const int
IntlChar::BLOCK_CODE_LINEAR_B_SYLLABARY
=
117 ;
const int
IntlChar::BLOCK_CODE_LINEAR_B_IDEOGRAMS
=
118 ;
const int
IntlChar::BLOCK_CODE_AEGEAN_NUMBERS
=
119 ;
const int
IntlChar::BLOCK_CODE_UGARITIC
= 120
;
const int
IntlChar::BLOCK_CODE_SHAVIAN
= 121 ;
const int
IntlChar::BLOCK_CODE_OSMANYA
= 122 ;
const int
IntlChar::BLOCK_CODE_CYPRIOT_SYLLABARY
=
123 ;
const int
IntlChar::BLOCK_CODE_TAI_XUAN_JING_SYMBOLS
= 124 ;
const int
IntlChar::BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT
<span
class="initializer"> = 125 ;
const int
IntlChar::BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION
<span
class="initializer"> = 126 ;
const int
IntlChar::BLOCK_CODE_ANCIENT_GREEK_NUMBERS
= 127 ;
const int
IntlChar::BLOCK_CODE_ARABIC_SUPPLEMENT
=
128 ;
const int
IntlChar::BLOCK_CODE_BUGINESE
= 129
;
const int
IntlChar::BLOCK_CODE_CJK_STROKES
=
130 ;
const int
IntlChar::BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT
<span
class="initializer"> = 131 ;
const int
IntlChar::BLOCK_CODE_COPTIC
= 132 ;
const int
IntlChar::BLOCK_CODE_ETHIOPIC_EXTENDED
=
133 ;
const int
IntlChar::BLOCK_CODE_ETHIOPIC_SUPPLEMENT
=
134 ;
const int
IntlChar::BLOCK_CODE_GEORGIAN_SUPPLEMENT
=
135 ;
const int
IntlChar::BLOCK_CODE_GLAGOLITIC
=
136 ;
const int
IntlChar::BLOCK_CODE_KHAROSHTHI
=
137 ;
const int
IntlChar::BLOCK_CODE_MODIFIER_TONE_LETTERS
= 138 ;
const int
IntlChar::BLOCK_CODE_NEW_TAI_LUE
=
139 ;
const int
IntlChar::BLOCK_CODE_OLD_PERSIAN
=
140 ;
const int
IntlChar::BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT
<span
class="initializer"> = 141 ;
const int
IntlChar::BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION
<span
class="initializer"> = 142 ;
const int
IntlChar::BLOCK_CODE_SYLOTI_NAGRI
=
143 ;
const int
IntlChar::BLOCK_CODE_TIFINAGH
= 144
;
const int
IntlChar::BLOCK_CODE_VERTICAL_FORMS
=
145 ;
const int
IntlChar::BLOCK_CODE_NKO
= 146 ;
const int
IntlChar::BLOCK_CODE_BALINESE
= 147
;
const int
IntlChar::BLOCK_CODE_LATIN_EXTENDED_C
=
148 ;
const int
IntlChar::BLOCK_CODE_LATIN_EXTENDED_D
=
149 ;
const int
IntlChar::BLOCK_CODE_PHAGS_PA
= 150
;
const int
IntlChar::BLOCK_CODE_PHOENICIAN
=
151 ;
const int
IntlChar::BLOCK_CODE_CUNEIFORM
= 152
;
const int
IntlChar::BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION
<span
class="initializer"> = 153 ;
const int
IntlChar::BLOCK_CODE_COUNTING_ROD_NUMERALS
= 154 ;
const int
IntlChar::BLOCK_CODE_SUNDANESE
= 155
;
const int
IntlChar::BLOCK_CODE_LEPCHA
= 156 ;
const int
IntlChar::BLOCK_CODE_OL_CHIKI
= 157
;
const int
IntlChar::BLOCK_CODE_CYRILLIC_EXTENDED_A
=
158 ;
const int
IntlChar::BLOCK_CODE_VAI
= 159 ;
const int
IntlChar::BLOCK_CODE_CYRILLIC_EXTENDED_B
=
160 ;
const int
IntlChar::BLOCK_CODE_SAURASHTRA
=
161 ;
const int
IntlChar::BLOCK_CODE_KAYAH_LI
= 162
;
const int
IntlChar::BLOCK_CODE_REJANG
= 163 ;
const int
IntlChar::BLOCK_CODE_CHAM
= 164 ;
const int
IntlChar::BLOCK_CODE_ANCIENT_SYMBOLS
=
165 ;
const int
IntlChar::BLOCK_CODE_PHAISTOS_DISC
=
166 ;
const int
IntlChar::BLOCK_CODE_LYCIAN
= 167 ;
const int
IntlChar::BLOCK_CODE_CARIAN
= 168 ;
const int
IntlChar::BLOCK_CODE_LYDIAN
= 169 ;
const int
IntlChar::BLOCK_CODE_MAHJONG_TILES
=
170 ;
const int
IntlChar::BLOCK_CODE_DOMINO_TILES
=
171 ;
const int
IntlChar::BLOCK_CODE_SAMARITAN
= 172
;
const int
IntlChar::BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED
= 173 ;
const int
IntlChar::BLOCK_CODE_TAI_THAM
= 174
;
const int
IntlChar::BLOCK_CODE_VEDIC_EXTENSIONS
=
175 ;
const int
IntlChar::BLOCK_CODE_LISU
= 176 ;
const int
IntlChar::BLOCK_CODE_BAMUM
= 177 ;
const int
IntlChar::BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS
<span
class="initializer"> = 178 ;
const int
IntlChar::BLOCK_CODE_DEVANAGARI_EXTENDED
=
179 ;
const int
IntlChar::BLOCK_CODE_HANGUL_JAMO_EXTENDED_A
= 180 ;
const int
IntlChar::BLOCK_CODE_JAVANESE
= 181
;
const int
IntlChar::BLOCK_CODE_MYANMAR_EXTENDED_A
=
182 ;
const int
IntlChar::BLOCK_CODE_TAI_VIET
= 183
;
const int
IntlChar::BLOCK_CODE_MEETEI_MAYEK
=
184 ;
const int
IntlChar::BLOCK_CODE_HANGUL_JAMO_EXTENDED_B
= 185 ;
const int
IntlChar::BLOCK_CODE_IMPERIAL_ARAMAIC
=
186 ;
const int
IntlChar::BLOCK_CODE_OLD_SOUTH_ARABIAN
=
187 ;
const int
IntlChar::BLOCK_CODE_AVESTAN
= 188 ;
const int
IntlChar::BLOCK_CODE_INSCRIPTIONAL_PARTHIAN
= 189 ;
const int
IntlChar::BLOCK_CODE_INSCRIPTIONAL_PAHLAVI
= 190 ;
const int
IntlChar::BLOCK_CODE_OLD_TURKIC
=
191 ;
const int
IntlChar::BLOCK_CODE_RUMI_NUMERAL_SYMBOLS
=
192 ;
const int
IntlChar::BLOCK_CODE_KAITHI
= 193 ;
const int
IntlChar::BLOCK_CODE_EGYPTIAN_HIEROGLYPHS
=
194 ;
const int
IntlChar::BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT
<span
class="initializer"> = 195 ;
const int
IntlChar::BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT
<span
class="initializer"> = 196 ;
const int
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C
<span
class="initializer"> = 197 ;
const int
IntlChar::BLOCK_CODE_MANDAIC
= 198 ;
const int
IntlChar::BLOCK_CODE_BATAK
= 199 ;
const int
IntlChar::BLOCK_CODE_ETHIOPIC_EXTENDED_A
=
200 ;
const int
IntlChar::BLOCK_CODE_BRAHMI
= 201 ;
const int
IntlChar::BLOCK_CODE_BAMUM_SUPPLEMENT
=
202 ;
const int
IntlChar::BLOCK_CODE_KANA_SUPPLEMENT
=
203 ;
const int
IntlChar::BLOCK_CODE_PLAYING_CARDS
=
204 ;
const int
IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS
<span
class="initializer"> = 205 ;
const int
IntlChar::BLOCK_CODE_EMOTICONS
= 206
;
const int
IntlChar::BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS
<span
class="initializer"> = 207 ;
const int
IntlChar::BLOCK_CODE_ALCHEMICAL_SYMBOLS
=
208 ;
const int
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D
<span
class="initializer"> = 209 ;
const int
IntlChar::BLOCK_CODE_ARABIC_EXTENDED_A
=
210 ;
const int
IntlChar::BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS
<span
class="initializer"> = 211 ;
const int
IntlChar::BLOCK_CODE_CHAKMA
= 212 ;
const int
IntlChar::BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS
<span
class="initializer"> = 213 ;
const int
IntlChar::BLOCK_CODE_MEROITIC_CURSIVE
=
214 ;
const int
IntlChar::BLOCK_CODE_MEROITIC_HIEROGLYPHS
=
215 ;
const int
IntlChar::BLOCK_CODE_MIAO
= 216 ;
const int
IntlChar::BLOCK_CODE_SHARADA
= 217 ;
const int
IntlChar::BLOCK_CODE_SORA_SOMPENG
=
218 ;
const int
IntlChar::BLOCK_CODE_SUNDANESE_SUPPLEMENT
=
219 ;
const int
IntlChar::BLOCK_CODE_TAKRI
= 220 ;
const int
IntlChar::BLOCK_CODE_COUNT
= 221 ;
const int
IntlChar::BLOCK_CODE_INVALID_CODE
=
-1 ;
const int
IntlChar::BPT_NONE
= 0 ;
const int
IntlChar::BPT_OPEN
= 1 ;
const int
IntlChar::BPT_CLOSE
= 2 ;
const int
IntlChar::BPT_COUNT
= 3 ;
const int
IntlChar::EA_NEUTRAL
= 0 ;
const int
IntlChar::EA_AMBIGUOUS
= 1 ;
const int
IntlChar::EA_HALFWIDTH
= 2 ;
const int
IntlChar::EA_FULLWIDTH
= 3 ;
const int
IntlChar::EA_NARROW
= 4 ;
const int
IntlChar::EA_WIDE
= 5 ;
const int
IntlChar::EA_COUNT
= 6 ;
const int
IntlChar::UNICODE_CHAR_NAME
= 0 ;
const int
IntlChar::UNICODE_10_CHAR_NAME
= 1 ;
const int
IntlChar::EXTENDED_CHAR_NAME
= 2 ;
const int
IntlChar::CHAR_NAME_ALIAS
= 3 ;
const int
IntlChar::CHAR_NAME_CHOICE_COUNT
= 4
;
const int
IntlChar::SHORT_PROPERTY_NAME
= 0 ;
const int
IntlChar::LONG_PROPERTY_NAME
= 1 ;
const int
IntlChar::PROPERTY_NAME_CHOICE_COUNT
=
2 ;
const int
IntlChar::DT_NONE
= 0 ;
const int
IntlChar::DT_CANONICAL
= 1 ;
const int
IntlChar::DT_COMPAT
= 2 ;
const int
IntlChar::DT_CIRCLE
= 3 ;
const int
IntlChar::DT_FINAL
= 4 ;
const int
IntlChar::DT_FONT
= 5 ;
const int
IntlChar::DT_FRACTION
= 6 ;
const int
IntlChar::DT_INITIAL
= 7 ;
const int
IntlChar::DT_ISOLATED
= 8 ;
const int
IntlChar::DT_MEDIAL
= 9 ;
const int
IntlChar::DT_NARROW
= 10 ;
const int
IntlChar::DT_NOBREAK
= 11 ;
const int
IntlChar::DT_SMALL
= 12 ;
const int
IntlChar::DT_SQUARE
= 13 ;
const int
IntlChar::DT_SUB
= 14 ;
const int
IntlChar::DT_SUPER
= 15 ;
const int
IntlChar::DT_VERTICAL
= 16 ;
const int
IntlChar::DT_WIDE
= 17 ;
const int
IntlChar::DT_COUNT
= 18 ;
const int
IntlChar::JT_NON_JOINING
= 0 ;
const int
IntlChar::JT_JOIN_CAUSING
= 1 ;
const int
IntlChar::JT_DUAL_JOINING
= 2 ;
const int
IntlChar::JT_LEFT_JOINING
= 3 ;
const int
IntlChar::JT_RIGHT_JOINING
= 4 ;
const int
IntlChar::JT_TRANSPARENT
= 5 ;
const int
IntlChar::JT_COUNT
= 6 ;
const int
IntlChar::JG_NO_JOINING_GROUP
= 0 ;
const int
IntlChar::JG_AIN
= 1 ;
const int
IntlChar::JG_ALAPH
= 2 ;
const int
IntlChar::JG_ALEF
= 3 ;
const int
IntlChar::JG_BEH
= 4 ;
const int
IntlChar::JG_BETH
= 5 ;
const int
IntlChar::JG_DAL
= 6 ;
const int
IntlChar::JG_DALATH_RISH
= 7 ;
const int
IntlChar::JG_E
= 8 ;
const int
IntlChar::JG_FEH
= 9 ;
const int
IntlChar::JG_FINAL_SEMKATH
= 10 ;
const int
IntlChar::JG_GAF
= 11 ;
const int
IntlChar::JG_GAMAL
= 12 ;
const int
IntlChar::JG_HAH
= 13 ;
const int
IntlChar::JG_TEH_MARBUTA_GOAL
= 14 ;
const int
IntlChar::JG_HAMZA_ON_HEH_GOAL
= 14
;
const int
IntlChar::JG_HE
= 15 ;
const int
IntlChar::JG_HEH
= 16 ;
const int
IntlChar::JG_HEH_GOAL
= 17 ;
const int
IntlChar::JG_HETH
= 18 ;
const int
IntlChar::JG_KAF
= 19 ;
const int
IntlChar::JG_KAPH
= 20 ;
const int
IntlChar::JG_KNOTTED_HEH
= 21 ;
const int
IntlChar::JG_LAM
= 22 ;
const int
IntlChar::JG_LAMADH
= 23 ;
const int
IntlChar::JG_MEEM
= 24 ;
const int
IntlChar::JG_MIM
= 25 ;
const int
IntlChar::JG_NOON
= 26 ;
const int
IntlChar::JG_NUN
= 27 ;
const int
IntlChar::JG_PE
= 28 ;
const int
IntlChar::JG_QAF
= 29 ;
const int
IntlChar::JG_QAPH
= 30 ;
const int
IntlChar::JG_REH
= 31 ;
const int
IntlChar::JG_REVERSED_PE
= 32 ;
const int
IntlChar::JG_SAD
= 33 ;
const int
IntlChar::JG_SADHE
= 34 ;
const int
IntlChar::JG_SEEN
= 35 ;
const int
IntlChar::JG_SEMKATH
= 36 ;
const int
IntlChar::JG_SHIN
= 37 ;
const int
IntlChar::JG_SWASH_KAF
= 38 ;
const int
IntlChar::JG_SYRIAC_WAW
= 39 ;
const int
IntlChar::JG_TAH
= 40 ;
const int
IntlChar::JG_TAW
= 41 ;
const int
IntlChar::JG_TEH_MARBUTA
= 42 ;
const int
IntlChar::JG_TETH
= 43 ;
const int
IntlChar::JG_WAW
= 44 ;
const int
IntlChar::JG_YEH
= 45 ;
const int
IntlChar::JG_YEH_BARREE
= 46 ;
const int
IntlChar::JG_YEH_WITH_TAIL
= 47 ;
const int
IntlChar::JG_YUDH
= 48 ;
const int
IntlChar::JG_YUDH_HE
= 49 ;
const int
IntlChar::JG_ZAIN
= 50 ;
const int
IntlChar::JG_FE
= 51 ;
const int
IntlChar::JG_KHAPH
= 52 ;
const int
IntlChar::JG_ZHAIN
= 53 ;
const int
IntlChar::JG_BURUSHASKI_YEH_BARREE
=
54 ;
const int
IntlChar::JG_FARSI_YEH
= 55 ;
const int
IntlChar::JG_NYA
= 56 ;
const int
IntlChar::JG_ROHINGYA_YEH
= 57 ;
const int
IntlChar::JG_COUNT
= 58 ;
const int
IntlChar::GCB_OTHER
= 0 ;
const int
IntlChar::GCB_CONTROL
= 1 ;
const int
IntlChar::GCB_CR
= 2 ;
const int
IntlChar::GCB_EXTEND
= 3 ;
const int
IntlChar::GCB_L
= 4 ;
const int
IntlChar::GCB_LF
= 5 ;
const int
IntlChar::GCB_LV
= 6 ;
const int
IntlChar::GCB_LVT
= 7 ;
const int
IntlChar::GCB_T
= 8 ;
const int
IntlChar::GCB_V
= 9 ;
const int
IntlChar::GCB_SPACING_MARK
= 10 ;
const int
IntlChar::GCB_PREPEND
= 11 ;
const int
IntlChar::GCB_REGIONAL_INDICATOR
=
12 ;
const int
IntlChar::GCB_COUNT
= 13 ;
const int
IntlChar::WB_OTHER
= 0 ;
const int
IntlChar::WB_ALETTER
= 1 ;
const int
IntlChar::WB_FORMAT
= 2 ;
const int
IntlChar::WB_KATAKANA
= 3 ;
const int
IntlChar::WB_MIDLETTER
= 4 ;
const int
IntlChar::WB_MIDNUM
= 5 ;
const int
IntlChar::WB_NUMERIC
= 6 ;
const int
IntlChar::WB_EXTENDNUMLET
= 7 ;
const int
IntlChar::WB_CR
= 8 ;
const int
IntlChar::WB_EXTEND
= 9 ;
const int
IntlChar::WB_LF
= 10 ;
const int
IntlChar::WB_MIDNUMLET
= 11 ;
const int
IntlChar::WB_NEWLINE
= 12 ;
const int
IntlChar::WB_REGIONAL_INDICATOR
= 13
;
const int
IntlChar::WB_HEBREW_LETTER
= 14 ;
const int
IntlChar::WB_SINGLE_QUOTE
= 15 ;
const int
IntlChar::WB_DOUBLE_QUOTE
= 16 ;
const int
IntlChar::WB_COUNT
= 17 ;
const int
IntlChar::SB_OTHER
= 0 ;
const int
IntlChar::SB_ATERM
= 1 ;
const int
IntlChar::SB_CLOSE
= 2 ;
const int
IntlChar::SB_FORMAT
= 3 ;
const int
IntlChar::SB_LOWER
= 4 ;
const int
IntlChar::SB_NUMERIC
= 5 ;
const int
IntlChar::SB_OLETTER
= 6 ;
const int
IntlChar::SB_SEP
= 7 ;
const int
IntlChar::SB_SP
= 8 ;
const int
IntlChar::SB_STERM
= 9 ;
const int
IntlChar::SB_UPPER
= 10 ;
const int
IntlChar::SB_CR
= 11 ;
const int
IntlChar::SB_EXTEND
= 12 ;
const int
IntlChar::SB_LF
= 13 ;
const int
IntlChar::SB_SCONTINUE
= 14 ;
const int
IntlChar::SB_COUNT
= 15 ;
const int
IntlChar::LB_UNKNOWN
= 0 ;
const int
IntlChar::LB_AMBIGUOUS
= 1 ;
const int
IntlChar::LB_ALPHABETIC
= 2 ;
const int
IntlChar::LB_BREAK_BOTH
= 3 ;
const int
IntlChar::LB_BREAK_AFTER
= 4 ;
const int
IntlChar::LB_BREAK_BEFORE
= 5 ;
const int
IntlChar::LB_MANDATORY_BREAK
= 6 ;
const int
IntlChar::LB_CONTINGENT_BREAK
= 7 ;
const int
IntlChar::LB_CLOSE_PUNCTUATION
= 8 ;
const int
IntlChar::LB_COMBINING_MARK
= 9 ;
const int
IntlChar::LB_CARRIAGE_RETURN
= 10 ;
const int
IntlChar::LB_EXCLAMATION
= 11 ;
const int
IntlChar::LB_GLUE
= 12 ;
const int
IntlChar::LB_HYPHEN
= 13 ;
const int
IntlChar::LB_IDEOGRAPHIC
= 14 ;
const int
IntlChar::LB_INSEPARABLE
= 15 ;
const int
IntlChar::LB_INSEPERABLE
= 15 ;
const int
IntlChar::LB_INFIX_NUMERIC
= 16 ;
const int
IntlChar::LB_LINE_FEED
= 17 ;
const int
IntlChar::LB_NONSTARTER
= 18 ;
const int
IntlChar::LB_NUMERIC
= 19 ;
const int
IntlChar::LB_OPEN_PUNCTUATION
= 20 ;
const int
IntlChar::LB_POSTFIX_NUMERIC
= 21 ;
const int
IntlChar::LB_PREFIX_NUMERIC
= 22 ;
const int
IntlChar::LB_QUOTATION
= 23 ;
const int
IntlChar::LB_COMPLEX_CONTEXT
= 24 ;
const int
IntlChar::LB_SURROGATE
= 25 ;
const int
IntlChar::LB_SPACE
= 26 ;
const int
IntlChar::LB_BREAK_SYMBOLS
= 27 ;
const int
IntlChar::LB_ZWSPACE
= 28 ;
const int
IntlChar::LB_NEXT_LINE
= 29 ;
const int
IntlChar::LB_WORD_JOINER
= 30 ;
const int
IntlChar::LB_H2
= 31 ;
const int
IntlChar::LB_H3
= 32 ;
const int
IntlChar::LB_JL
= 33 ;
const int
IntlChar::LB_JT
= 34 ;
const int
IntlChar::LB_JV
= 35 ;
const int
IntlChar::LB_CLOSE_PARENTHESIS
= 36
;
const int
IntlChar::LB_CONDITIONAL_JAPANESE_STARTER
=
37 ;
const int
IntlChar::LB_HEBREW_LETTER
= 38 ;
const int
IntlChar::LB_REGIONAL_INDICATOR
= 39
;
const int
IntlChar::LB_COUNT
= 40 ;
const int
IntlChar::NT_NONE
= 0 ;
const int
IntlChar::NT_DECIMAL
= 1 ;
const int
IntlChar::NT_DIGIT
= 2 ;
const int
IntlChar::NT_NUMERIC
= 3 ;
const int
IntlChar::NT_COUNT
= 4 ;
const int
IntlChar::HST_NOT_APPLICABLE
= 0 ;
const int
IntlChar::HST_LEADING_JAMO
= 1 ;
const int
IntlChar::HST_VOWEL_JAMO
= 2 ;
const int
IntlChar::HST_TRAILING_JAMO
= 3 ;
const int
IntlChar::HST_LV_SYLLABLE
= 4 ;
const int
IntlChar::HST_LVT_SYLLABLE
= 5 ;
const int
IntlChar::HST_COUNT
= 6 ;
/* 方法 */
public <span
class="modifier">static array <span
class="methodname">charAge ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static int <span
class="methodname">charDigitValue ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static int <span
class="methodname">charDirection ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static int <span
class="methodname">charFromName ( <span
class="type">string $characterName
[, <span
class="methodparam">int $nameChoice
<span
class="initializer"> = IntlChar::UNICODE_CHAR_NAME
] )
public <span
class="modifier">static mixed <span
class="methodname">charMirror ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static string <span
class="methodname">charName ( <span
class="type">mixed $codepoint
[, <span
class="methodparam">int $nameChoice
<span
class="initializer"> = IntlChar::UNICODE_CHAR_NAME
] )
public <span
class="modifier">static int <span
class="methodname">charType ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static string <span
class="methodname">chr ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static int <span
class="methodname">digit ( <span
class="type">string $codepoint
[, <span
class="methodparam">int $radix
<span
class="initializer"> = 10 ] )
public <span
class="modifier">static void <span
class="methodname">enumCharNames ( <span
class="methodparam">mixed $start
,
mixed
$limit
, <span
class="type">callable $callback
[, <span
class="methodparam">int $nameChoice
<span
class="initializer"> = IntlChar::UNICODE_CHAR_NAME
] )
public <span
class="modifier">static void <span
class="methodname">enumCharTypes ( <span
class="methodparam">callable
$callback
)
public <span
class="modifier">static mixed <span
class="methodname">foldCase ( <span
class="type">mixed $codepoint
[, <span
class="methodparam">int $options
<span
class="initializer"> = IntlChar::FOLD_CASE_DEFAULT
] )
public <span
class="modifier">static int <span
class="methodname">forDigit ( <span
class="type">int $digit
[, <span
class="methodparam">int $radix
<span
class="initializer"> = 10 ] )
public <span
class="modifier">static mixed <span
class="methodname">getBidiPairedBracket ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static int <span
class="methodname">getBlockCode ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static int <span
class="methodname">getCombiningClass ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static string <span
class="methodname">getFC_NFKC_Closure ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static int <span
class="methodname">getIntPropertyMaxValue ( <span
class="methodparam">int $property
)
public <span
class="modifier">static int <span
class="methodname">getIntPropertyMinValue ( <span
class="methodparam">int $property
)
public <span
class="modifier">static int <span
class="methodname">getIntPropertyValue ( <span
class="methodparam">mixed $codepoint
, int
$property
)
public <span
class="modifier">static float <span
class="methodname">getNumericValue ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static int <span
class="methodname">getPropertyEnum ( <span
class="methodparam">string $alias
)
public <span
class="modifier">static string <span
class="methodname">getPropertyName ( <span
class="methodparam">int $property
[,
int
$nameChoice
=
IntlChar::LONG_PROPERTY_NAME
] )
public <span
class="modifier">static int <span
class="methodname">getPropertyValueEnum ( <span
class="methodparam">int $property
,
string
$name
)
public <span
class="modifier">static string <span
class="methodname">getPropertyValueName ( <span
class="methodparam">int $property
,
int $value
[, int
$nameChoice
=
IntlChar::LONG_PROPERTY_NAME
] )
public <span class="modifier">static array <span class="methodname">getUnicodeVersion ( <span class="methodparam">void )
public <span
class="modifier">static bool <span
class="methodname">hasBinaryProperty ( <span
class="methodparam">mixed $codepoint
, int
$property
)
public <span
class="modifier">static bool <span
class="methodname">isalnum ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isalpha ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isbase ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isblank ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">iscntrl ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isdefined ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isdigit ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isgraph ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isIDIgnorable ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isIDPart ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isIDStart ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isISOControl ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isJavaIDPart ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isJavaIDStart ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isJavaSpaceChar ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">islower ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isMirrored ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isprint ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">ispunct ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isspace ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">istitle ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isUAlphabetic ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isULowercase ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isupper ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isUUppercase ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isUWhiteSpace ( <span
class="methodparam">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isWhitespace ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static bool <span
class="methodname">isxdigit ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static int <span
class="methodname">ord ( <span
class="type">mixed $character
)
public <span
class="modifier">static mixed <span
class="methodname">tolower ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static mixed <span
class="methodname">totitle ( <span
class="type">mixed $codepoint
)
public <span
class="modifier">static mixed <span
class="methodname">toupper ( <span
class="type">mixed $codepoint
)
}
预定义常量
IntlChar::UNICODE_VERSION
IntlChar::CODEPOINT_MIN
IntlChar::CODEPOINT_MAX
IntlChar::NO_NUMERIC_VALUE
Special value that is returned by <span
class="methodname">IntlChar::getNumericValue when no numeric
value is defined for a code point.
IntlChar::PROPERTY_ALPHABETIC
IntlChar::PROPERTY_BINARY_START
IntlChar::PROPERTY_ASCII_HEX_DIGIT
IntlChar::PROPERTY_BIDI_CONTROL
IntlChar::PROPERTY_BIDI_MIRRORED
IntlChar::PROPERTY_DASH
IntlChar::PROPERTY_DEFAULT_IGNORABLE_CODE_POINT
IntlChar::PROPERTY_DEPRECATED
IntlChar::PROPERTY_DIACRITIC
IntlChar::PROPERTY_EXTENDER
IntlChar::PROPERTY_FULL_COMPOSITION_EXCLUSION
IntlChar::PROPERTY_GRAPHEME_BASE
IntlChar::PROPERTY_GRAPHEME_EXTEND
IntlChar::PROPERTY_GRAPHEME_LINK
IntlChar::PROPERTY_HEX_DIGIT
IntlChar::PROPERTY_HYPHEN
IntlChar::PROPERTY_ID_CONTINUE
IntlChar::PROPERTY_ID_START
IntlChar::PROPERTY_IDEOGRAPHIC
IntlChar::PROPERTY_IDS_BINARY_OPERATOR
IntlChar::PROPERTY_IDS_TRINARY_OPERATOR
IntlChar::PROPERTY_JOIN_CONTROL
IntlChar::PROPERTY_LOGICAL_ORDER_EXCEPTION
IntlChar::PROPERTY_LOWERCASE
IntlChar::PROPERTY_MATH
IntlChar::PROPERTY_NONCHARACTER_CODE_POINT
IntlChar::PROPERTY_QUOTATION_MARK
IntlChar::PROPERTY_RADICAL
IntlChar::PROPERTY_SOFT_DOTTED
IntlChar::PROPERTY_TERMINAL_PUNCTUATION
IntlChar::PROPERTY_UNIFIED_IDEOGRAPH
IntlChar::PROPERTY_UPPERCASE
IntlChar::PROPERTY_WHITE_SPACE
IntlChar::PROPERTY_XID_CONTINUE
IntlChar::PROPERTY_XID_START
IntlChar::PROPERTY_CASE_SENSITIVE
IntlChar::PROPERTY_S_TERM
IntlChar::PROPERTY_VARIATION_SELECTOR
IntlChar::PROPERTY_NFD_INERT
IntlChar::PROPERTY_NFKD_INERT
IntlChar::PROPERTY_NFC_INERT
IntlChar::PROPERTY_NFKC_INERT
IntlChar::PROPERTY_SEGMENT_STARTER
IntlChar::PROPERTY_PATTERN_SYNTAX
IntlChar::PROPERTY_PATTERN_WHITE_SPACE
IntlChar::PROPERTY_POSIX_ALNUM
IntlChar::PROPERTY_POSIX_BLANK
IntlChar::PROPERTY_POSIX_GRAPH
IntlChar::PROPERTY_POSIX_PRINT
IntlChar::PROPERTY_POSIX_XDIGIT
IntlChar::PROPERTY_CASED
IntlChar::PROPERTY_CASE_IGNORABLE
IntlChar::PROPERTY_CHANGES_WHEN_LOWERCASED
IntlChar::PROPERTY_CHANGES_WHEN_UPPERCASED
IntlChar::PROPERTY_CHANGES_WHEN_TITLECASED
IntlChar::PROPERTY_CHANGES_WHEN_CASEFOLDED
IntlChar::PROPERTY_CHANGES_WHEN_CASEMAPPED
IntlChar::PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED
IntlChar::PROPERTY_BINARY_LIMIT
IntlChar::PROPERTY_BIDI_CLASS
IntlChar::PROPERTY_INT_START
IntlChar::PROPERTY_BLOCK
IntlChar::PROPERTY_CANONICAL_COMBINING_CLASS
IntlChar::PROPERTY_DECOMPOSITION_TYPE
IntlChar::PROPERTY_EAST_ASIAN_WIDTH
IntlChar::PROPERTY_GENERAL_CATEGORY
IntlChar::PROPERTY_JOINING_GROUP
IntlChar::PROPERTY_JOINING_TYPE
IntlChar::PROPERTY_LINE_BREAK
IntlChar::PROPERTY_NUMERIC_TYPE
IntlChar::PROPERTY_SCRIPT
IntlChar::PROPERTY_HANGUL_SYLLABLE_TYPE
IntlChar::PROPERTY_NFD_QUICK_CHECK
IntlChar::PROPERTY_NFKD_QUICK_CHECK
IntlChar::PROPERTY_NFC_QUICK_CHECK
IntlChar::PROPERTY_NFKC_QUICK_CHECK
IntlChar::PROPERTY_LEAD_CANONICAL_COMBINING_CLASS
IntlChar::PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS
IntlChar::PROPERTY_GRAPHEME_CLUSTER_BREAK
IntlChar::PROPERTY_SENTENCE_BREAK
IntlChar::PROPERTY_WORD_BREAK
IntlChar::PROPERTY_BIDI_PAIRED_BRACKET_TYPE
IntlChar::PROPERTY_INT_LIMIT
IntlChar::PROPERTY_GENERAL_CATEGORY_MASK
IntlChar::PROPERTY_MASK_START
IntlChar::PROPERTY_MASK_LIMIT
IntlChar::PROPERTY_NUMERIC_VALUE
IntlChar::PROPERTY_DOUBLE_START
IntlChar::PROPERTY_DOUBLE_LIMIT
IntlChar::PROPERTY_AGE
IntlChar::PROPERTY_STRING_START
IntlChar::PROPERTY_BIDI_MIRRORING_GLYPH
IntlChar::PROPERTY_CASE_FOLDING
IntlChar::PROPERTY_ISO_COMMENT
IntlChar::PROPERTY_LOWERCASE_MAPPING
IntlChar::PROPERTY_NAME
IntlChar::PROPERTY_SIMPLE_CASE_FOLDING
IntlChar::PROPERTY_SIMPLE_LOWERCASE_MAPPING
IntlChar::PROPERTY_SIMPLE_TITLECASE_MAPPING
IntlChar::PROPERTY_SIMPLE_UPPERCASE_MAPPING
IntlChar::PROPERTY_TITLECASE_MAPPING
IntlChar::PROPERTY_UNICODE_1_NAME
IntlChar::PROPERTY_UPPERCASE_MAPPING
IntlChar::PROPERTY_BIDI_PAIRED_BRACKET
IntlChar::PROPERTY_STRING_LIMIT
IntlChar::PROPERTY_SCRIPT_EXTENSIONS
IntlChar::PROPERTY_OTHER_PROPERTY_START
IntlChar::PROPERTY_OTHER_PROPERTY_LIMIT
IntlChar::PROPERTY_INVALID_CODE
IntlChar::CHAR_CATEGORY_UNASSIGNED
IntlChar::CHAR_CATEGORY_GENERAL_OTHER_TYPES
IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER
IntlChar::CHAR_CATEGORY_LOWERCASE_LETTER
IntlChar::CHAR_CATEGORY_TITLECASE_LETTER
IntlChar::CHAR_CATEGORY_MODIFIER_LETTER
IntlChar::CHAR_CATEGORY_OTHER_LETTER
IntlChar::CHAR_CATEGORY_NON_SPACING_MARK
IntlChar::CHAR_CATEGORY_ENCLOSING_MARK
IntlChar::CHAR_CATEGORY_COMBINING_SPACING_MARK
IntlChar::CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER
IntlChar::CHAR_CATEGORY_LETTER_NUMBER
IntlChar::CHAR_CATEGORY_OTHER_NUMBER
IntlChar::CHAR_CATEGORY_SPACE_SEPARATOR
IntlChar::CHAR_CATEGORY_LINE_SEPARATOR
IntlChar::CHAR_CATEGORY_PARAGRAPH_SEPARATOR
IntlChar::CHAR_CATEGORY_CONTROL_CHAR
IntlChar::CHAR_CATEGORY_FORMAT_CHAR
IntlChar::CHAR_CATEGORY_PRIVATE_USE_CHAR
IntlChar::CHAR_CATEGORY_SURROGATE
IntlChar::CHAR_CATEGORY_DASH_PUNCTUATION
IntlChar::CHAR_CATEGORY_START_PUNCTUATION
IntlChar::CHAR_CATEGORY_END_PUNCTUATION
IntlChar::CHAR_CATEGORY_CONNECTOR_PUNCTUATION
IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION
IntlChar::CHAR_CATEGORY_MATH_SYMBOL
IntlChar::CHAR_CATEGORY_CURRENCY_SYMBOL
IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL
IntlChar::CHAR_CATEGORY_OTHER_SYMBOL
IntlChar::CHAR_CATEGORY_INITIAL_PUNCTUATION
IntlChar::CHAR_CATEGORY_FINAL_PUNCTUATION
IntlChar::CHAR_CATEGORY_CHAR_CATEGORY_COUNT
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR
IntlChar::CHAR_DIRECTION_ARABIC_NUMBER
IntlChar::CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR
IntlChar::CHAR_DIRECTION_BLOCK_SEPARATOR
IntlChar::CHAR_DIRECTION_SEGMENT_SEPARATOR
IntlChar::CHAR_DIRECTION_WHITE_SPACE_NEUTRAL
IntlChar::CHAR_DIRECTION_OTHER_NEUTRAL
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE
IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT
IntlChar::CHAR_DIRECTION_DIR_NON_SPACING_MARK
IntlChar::CHAR_DIRECTION_BOUNDARY_NEUTRAL
IntlChar::CHAR_DIRECTION_FIRST_STRONG_ISOLATE
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE
IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE
IntlChar::CHAR_DIRECTION_CHAR_DIRECTION_COUNT
IntlChar::BLOCK_CODE_NO_BLOCK
IntlChar::BLOCK_CODE_BASIC_LATIN
IntlChar::BLOCK_CODE_LATIN_1_SUPPLEMENT
IntlChar::BLOCK_CODE_LATIN_EXTENDED_A
IntlChar::BLOCK_CODE_LATIN_EXTENDED_B
IntlChar::BLOCK_CODE_IPA_EXTENSIONS
IntlChar::BLOCK_CODE_SPACING_MODIFIER_LETTERS
IntlChar::BLOCK_CODE_COMBINING_DIACRITICAL_MARKS
IntlChar::BLOCK_CODE_GREEK
IntlChar::BLOCK_CODE_CYRILLIC
IntlChar::BLOCK_CODE_ARMENIAN
IntlChar::BLOCK_CODE_HEBREW
IntlChar::BLOCK_CODE_ARABIC
IntlChar::BLOCK_CODE_SYRIAC
IntlChar::BLOCK_CODE_THAANA
IntlChar::BLOCK_CODE_DEVANAGARI
IntlChar::BLOCK_CODE_BENGALI
IntlChar::BLOCK_CODE_GURMUKHI
IntlChar::BLOCK_CODE_GUJARATI
IntlChar::BLOCK_CODE_ORIYA
IntlChar::BLOCK_CODE_TAMIL
IntlChar::BLOCK_CODE_TELUGU
IntlChar::BLOCK_CODE_KANNADA
IntlChar::BLOCK_CODE_MALAYALAM
IntlChar::BLOCK_CODE_SINHALA
IntlChar::BLOCK_CODE_THAI
IntlChar::BLOCK_CODE_LAO
IntlChar::BLOCK_CODE_TIBETAN
IntlChar::BLOCK_CODE_MYANMAR
IntlChar::BLOCK_CODE_GEORGIAN
IntlChar::BLOCK_CODE_HANGUL_JAMO
IntlChar::BLOCK_CODE_ETHIOPIC
IntlChar::BLOCK_CODE_CHEROKEE
IntlChar::BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS
IntlChar::BLOCK_CODE_OGHAM
IntlChar::BLOCK_CODE_RUNIC
IntlChar::BLOCK_CODE_KHMER
IntlChar::BLOCK_CODE_MONGOLIAN
IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL
IntlChar::BLOCK_CODE_GREEK_EXTENDED
IntlChar::BLOCK_CODE_GENERAL_PUNCTUATION
IntlChar::BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS
IntlChar::BLOCK_CODE_CURRENCY_SYMBOLS
IntlChar::BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS
IntlChar::BLOCK_CODE_LETTERLIKE_SYMBOLS
IntlChar::BLOCK_CODE_NUMBER_FORMS
IntlChar::BLOCK_CODE_ARROWS
IntlChar::BLOCK_CODE_MATHEMATICAL_OPERATORS
IntlChar::BLOCK_CODE_MISCELLANEOUS_TECHNICAL
IntlChar::BLOCK_CODE_CONTROL_PICTURES
IntlChar::BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION
IntlChar::BLOCK_CODE_ENCLOSED_ALPHANUMERICS
IntlChar::BLOCK_CODE_BOX_DRAWING
IntlChar::BLOCK_CODE_BLOCK_ELEMENTS
IntlChar::BLOCK_CODE_GEOMETRIC_SHAPES
IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS
IntlChar::BLOCK_CODE_DINGBATS
IntlChar::BLOCK_CODE_BRAILLE_PATTERNS
IntlChar::BLOCK_CODE_CJK_RADICALS_SUPPLEMENT
IntlChar::BLOCK_CODE_KANGXI_RADICALS
IntlChar::BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS
IntlChar::BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION
IntlChar::BLOCK_CODE_HIRAGANA
IntlChar::BLOCK_CODE_KATAKANA
IntlChar::BLOCK_CODE_BOPOMOFO
IntlChar::BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO
IntlChar::BLOCK_CODE_KANBUN
IntlChar::BLOCK_CODE_BOPOMOFO_EXTENDED
IntlChar::BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS
IntlChar::BLOCK_CODE_CJK_COMPATIBILITY
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS
IntlChar::BLOCK_CODE_YI_SYLLABLES
IntlChar::BLOCK_CODE_YI_RADICALS
IntlChar::BLOCK_CODE_HANGUL_SYLLABLES
IntlChar::BLOCK_CODE_HIGH_SURROGATES
IntlChar::BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES
IntlChar::BLOCK_CODE_LOW_SURROGATES
IntlChar::BLOCK_CODE_PRIVATE_USE_AREA
IntlChar::BLOCK_CODE_PRIVATE_USE
IntlChar::BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS
IntlChar::BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS
IntlChar::BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A
IntlChar::BLOCK_CODE_COMBINING_HALF_MARKS
IntlChar::BLOCK_CODE_CJK_COMPATIBILITY_FORMS
IntlChar::BLOCK_CODE_SMALL_FORM_VARIANTS
IntlChar::BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B
IntlChar::BLOCK_CODE_SPECIALS
IntlChar::BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS
IntlChar::BLOCK_CODE_OLD_ITALIC
IntlChar::BLOCK_CODE_GOTHIC
IntlChar::BLOCK_CODE_DESERET
IntlChar::BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS
IntlChar::BLOCK_CODE_MUSICAL_SYMBOLS
IntlChar::BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
IntlChar::BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT
IntlChar::BLOCK_CODE_TAGS
IntlChar::BLOCK_CODE_CYRILLIC_SUPPLEMENT
IntlChar::BLOCK_CODE_CYRILLIC_SUPPLEMENTARY
IntlChar::BLOCK_CODE_TAGALOG
IntlChar::BLOCK_CODE_HANUNOO
IntlChar::BLOCK_CODE_BUHID
IntlChar::BLOCK_CODE_TAGBANWA
IntlChar::BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A
IntlChar::BLOCK_CODE_SUPPLEMENTAL_ARROWS_A
IntlChar::BLOCK_CODE_SUPPLEMENTAL_ARROWS_B
IntlChar::BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B
IntlChar::BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS
IntlChar::BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS
IntlChar::BLOCK_CODE_VARIATION_SELECTORS
IntlChar::BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A
IntlChar::BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B
IntlChar::BLOCK_CODE_LIMBU
IntlChar::BLOCK_CODE_TAI_LE
IntlChar::BLOCK_CODE_KHMER_SYMBOLS
IntlChar::BLOCK_CODE_PHONETIC_EXTENSIONS
IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS
IntlChar::BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS
IntlChar::BLOCK_CODE_LINEAR_B_SYLLABARY
IntlChar::BLOCK_CODE_LINEAR_B_IDEOGRAMS
IntlChar::BLOCK_CODE_AEGEAN_NUMBERS
IntlChar::BLOCK_CODE_UGARITIC
IntlChar::BLOCK_CODE_SHAVIAN
IntlChar::BLOCK_CODE_OSMANYA
IntlChar::BLOCK_CODE_CYPRIOT_SYLLABARY
IntlChar::BLOCK_CODE_TAI_XUAN_JING_SYMBOLS
IntlChar::BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT
IntlChar::BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION
IntlChar::BLOCK_CODE_ANCIENT_GREEK_NUMBERS
IntlChar::BLOCK_CODE_ARABIC_SUPPLEMENT
IntlChar::BLOCK_CODE_BUGINESE
IntlChar::BLOCK_CODE_CJK_STROKES
IntlChar::BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT
IntlChar::BLOCK_CODE_COPTIC
IntlChar::BLOCK_CODE_ETHIOPIC_EXTENDED
IntlChar::BLOCK_CODE_ETHIOPIC_SUPPLEMENT
IntlChar::BLOCK_CODE_GEORGIAN_SUPPLEMENT
IntlChar::BLOCK_CODE_GLAGOLITIC
IntlChar::BLOCK_CODE_KHAROSHTHI
IntlChar::BLOCK_CODE_MODIFIER_TONE_LETTERS
IntlChar::BLOCK_CODE_NEW_TAI_LUE
IntlChar::BLOCK_CODE_OLD_PERSIAN
IntlChar::BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT
IntlChar::BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION
IntlChar::BLOCK_CODE_SYLOTI_NAGRI
IntlChar::BLOCK_CODE_TIFINAGH
IntlChar::BLOCK_CODE_VERTICAL_FORMS
IntlChar::BLOCK_CODE_NKO
IntlChar::BLOCK_CODE_BALINESE
IntlChar::BLOCK_CODE_LATIN_EXTENDED_C
IntlChar::BLOCK_CODE_LATIN_EXTENDED_D
IntlChar::BLOCK_CODE_PHAGS_PA
IntlChar::BLOCK_CODE_PHOENICIAN
IntlChar::BLOCK_CODE_CUNEIFORM
IntlChar::BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION
IntlChar::BLOCK_CODE_COUNTING_ROD_NUMERALS
IntlChar::BLOCK_CODE_SUNDANESE
IntlChar::BLOCK_CODE_LEPCHA
IntlChar::BLOCK_CODE_OL_CHIKI
IntlChar::BLOCK_CODE_CYRILLIC_EXTENDED_A
IntlChar::BLOCK_CODE_VAI
IntlChar::BLOCK_CODE_CYRILLIC_EXTENDED_B
IntlChar::BLOCK_CODE_SAURASHTRA
IntlChar::BLOCK_CODE_KAYAH_LI
IntlChar::BLOCK_CODE_REJANG
IntlChar::BLOCK_CODE_CHAM
IntlChar::BLOCK_CODE_ANCIENT_SYMBOLS
IntlChar::BLOCK_CODE_PHAISTOS_DISC
IntlChar::BLOCK_CODE_LYCIAN
IntlChar::BLOCK_CODE_CARIAN
IntlChar::BLOCK_CODE_LYDIAN
IntlChar::BLOCK_CODE_MAHJONG_TILES
IntlChar::BLOCK_CODE_DOMINO_TILES
IntlChar::BLOCK_CODE_SAMARITAN
IntlChar::BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED
IntlChar::BLOCK_CODE_TAI_THAM
IntlChar::BLOCK_CODE_VEDIC_EXTENSIONS
IntlChar::BLOCK_CODE_LISU
IntlChar::BLOCK_CODE_BAMUM
IntlChar::BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS
IntlChar::BLOCK_CODE_DEVANAGARI_EXTENDED
IntlChar::BLOCK_CODE_HANGUL_JAMO_EXTENDED_A
IntlChar::BLOCK_CODE_JAVANESE
IntlChar::BLOCK_CODE_MYANMAR_EXTENDED_A
IntlChar::BLOCK_CODE_TAI_VIET
IntlChar::BLOCK_CODE_MEETEI_MAYEK
IntlChar::BLOCK_CODE_HANGUL_JAMO_EXTENDED_B
IntlChar::BLOCK_CODE_IMPERIAL_ARAMAIC
IntlChar::BLOCK_CODE_OLD_SOUTH_ARABIAN
IntlChar::BLOCK_CODE_AVESTAN
IntlChar::BLOCK_CODE_INSCRIPTIONAL_PARTHIAN
IntlChar::BLOCK_CODE_INSCRIPTIONAL_PAHLAVI
IntlChar::BLOCK_CODE_OLD_TURKIC
IntlChar::BLOCK_CODE_RUMI_NUMERAL_SYMBOLS
IntlChar::BLOCK_CODE_KAITHI
IntlChar::BLOCK_CODE_EGYPTIAN_HIEROGLYPHS
IntlChar::BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT
IntlChar::BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C
IntlChar::BLOCK_CODE_MANDAIC
IntlChar::BLOCK_CODE_BATAK
IntlChar::BLOCK_CODE_ETHIOPIC_EXTENDED_A
IntlChar::BLOCK_CODE_BRAHMI
IntlChar::BLOCK_CODE_BAMUM_SUPPLEMENT
IntlChar::BLOCK_CODE_KANA_SUPPLEMENT
IntlChar::BLOCK_CODE_PLAYING_CARDS
IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS
IntlChar::BLOCK_CODE_EMOTICONS
IntlChar::BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS
IntlChar::BLOCK_CODE_ALCHEMICAL_SYMBOLS
IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D
IntlChar::BLOCK_CODE_ARABIC_EXTENDED_A
IntlChar::BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS
IntlChar::BLOCK_CODE_CHAKMA
IntlChar::BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS
IntlChar::BLOCK_CODE_MEROITIC_CURSIVE
IntlChar::BLOCK_CODE_MEROITIC_HIEROGLYPHS
IntlChar::BLOCK_CODE_MIAO
IntlChar::BLOCK_CODE_SHARADA
IntlChar::BLOCK_CODE_SORA_SOMPENG
IntlChar::BLOCK_CODE_SUNDANESE_SUPPLEMENT
IntlChar::BLOCK_CODE_TAKRI
IntlChar::BLOCK_CODE_COUNT
IntlChar::BLOCK_CODE_INVALID_CODE
IntlChar::BPT_NONE
IntlChar::BPT_OPEN
IntlChar::BPT_CLOSE
IntlChar::BPT_COUNT
IntlChar::EA_NEUTRAL
IntlChar::EA_AMBIGUOUS
IntlChar::EA_HALFWIDTH
IntlChar::EA_FULLWIDTH
IntlChar::EA_NARROW
IntlChar::EA_WIDE
IntlChar::EA_COUNT
IntlChar::UNICODE_CHAR_NAME
IntlChar::UNICODE_10_CHAR_NAME
IntlChar::EXTENDED_CHAR_NAME
IntlChar::CHAR_NAME_ALIAS
IntlChar::CHAR_NAME_CHOICE_COUNT
IntlChar::SHORT_PROPERTY_NAME
IntlChar::LONG_PROPERTY_NAME
IntlChar::PROPERTY_NAME_CHOICE_COUNT
IntlChar::DT_NONE
IntlChar::DT_CANONICAL
IntlChar::DT_COMPAT
IntlChar::DT_CIRCLE
IntlChar::DT_FINAL
IntlChar::DT_FONT
IntlChar::DT_FRACTION
IntlChar::DT_INITIAL
IntlChar::DT_ISOLATED
IntlChar::DT_MEDIAL
IntlChar::DT_NARROW
IntlChar::DT_NOBREAK
IntlChar::DT_SMALL
IntlChar::DT_SQUARE
IntlChar::DT_SUB
IntlChar::DT_SUPER
IntlChar::DT_VERTICAL
IntlChar::DT_WIDE
IntlChar::DT_COUNT
IntlChar::JT_NON_JOINING
IntlChar::JT_JOIN_CAUSING
IntlChar::JT_DUAL_JOINING
IntlChar::JT_LEFT_JOINING
IntlChar::JT_RIGHT_JOINING
IntlChar::JT_TRANSPARENT
IntlChar::JT_COUNT
IntlChar::JG_NO_JOINING_GROUP
IntlChar::JG_AIN
IntlChar::JG_ALAPH
IntlChar::JG_ALEF
IntlChar::JG_BEH
IntlChar::JG_BETH
IntlChar::JG_DAL
IntlChar::JG_DALATH_RISH
IntlChar::JG_E
IntlChar::JG_FEH
IntlChar::JG_FINAL_SEMKATH
IntlChar::JG_GAF
IntlChar::JG_GAMAL
IntlChar::JG_HAH
IntlChar::JG_TEH_MARBUTA_GOAL
IntlChar::JG_HAMZA_ON_HEH_GOAL
IntlChar::JG_HE
IntlChar::JG_HEH
IntlChar::JG_HEH_GOAL
IntlChar::JG_HETH
IntlChar::JG_KAF
IntlChar::JG_KAPH
IntlChar::JG_KNOTTED_HEH
IntlChar::JG_LAM
IntlChar::JG_LAMADH
IntlChar::JG_MEEM
IntlChar::JG_MIM
IntlChar::JG_NOON
IntlChar::JG_NUN
IntlChar::JG_PE
IntlChar::JG_QAF
IntlChar::JG_QAPH
IntlChar::JG_REH
IntlChar::JG_REVERSED_PE
IntlChar::JG_SAD
IntlChar::JG_SADHE
IntlChar::JG_SEEN
IntlChar::JG_SEMKATH
IntlChar::JG_SHIN
IntlChar::JG_SWASH_KAF
IntlChar::JG_SYRIAC_WAW
IntlChar::JG_TAH
IntlChar::JG_TAW
IntlChar::JG_TEH_MARBUTA
IntlChar::JG_TETH
IntlChar::JG_WAW
IntlChar::JG_YEH
IntlChar::JG_YEH_BARREE
IntlChar::JG_YEH_WITH_TAIL
IntlChar::JG_YUDH
IntlChar::JG_YUDH_HE
IntlChar::JG_ZAIN
IntlChar::JG_FE
IntlChar::JG_KHAPH
IntlChar::JG_ZHAIN
IntlChar::JG_BURUSHASKI_YEH_BARREE
IntlChar::JG_FARSI_YEH
IntlChar::JG_NYA
IntlChar::JG_ROHINGYA_YEH
IntlChar::JG_COUNT
IntlChar::GCB_OTHER
IntlChar::GCB_CONTROL
IntlChar::GCB_CR
IntlChar::GCB_EXTEND
IntlChar::GCB_L
IntlChar::GCB_LF
IntlChar::GCB_LV
IntlChar::GCB_LVT
IntlChar::GCB_T
IntlChar::GCB_V
IntlChar::GCB_SPACING_MARK
IntlChar::GCB_PREPEND
IntlChar::GCB_REGIONAL_INDICATOR
IntlChar::GCB_COUNT
IntlChar::WB_OTHER
IntlChar::WB_ALETTER
IntlChar::WB_FORMAT
IntlChar::WB_KATAKANA
IntlChar::WB_MIDLETTER
IntlChar::WB_MIDNUM
IntlChar::WB_NUMERIC
IntlChar::WB_EXTENDNUMLET
IntlChar::WB_CR
IntlChar::WB_EXTEND
IntlChar::WB_LF
IntlChar::WB_MIDNUMLET
IntlChar::WB_NEWLINE
IntlChar::WB_REGIONAL_INDICATOR
IntlChar::WB_HEBREW_LETTER
IntlChar::WB_SINGLE_QUOTE
IntlChar::WB_DOUBLE_QUOTE
IntlChar::WB_COUNT
IntlChar::SB_OTHER
IntlChar::SB_ATERM
IntlChar::SB_CLOSE
IntlChar::SB_FORMAT
IntlChar::SB_LOWER
IntlChar::SB_NUMERIC
IntlChar::SB_OLETTER
IntlChar::SB_SEP
IntlChar::SB_SP
IntlChar::SB_STERM
IntlChar::SB_UPPER
IntlChar::SB_CR
IntlChar::SB_EXTEND
IntlChar::SB_LF
IntlChar::SB_SCONTINUE
IntlChar::SB_COUNT
IntlChar::LB_UNKNOWN
IntlChar::LB_AMBIGUOUS
IntlChar::LB_ALPHABETIC
IntlChar::LB_BREAK_BOTH
IntlChar::LB_BREAK_AFTER
IntlChar::LB_BREAK_BEFORE
IntlChar::LB_MANDATORY_BREAK
IntlChar::LB_CONTINGENT_BREAK
IntlChar::LB_CLOSE_PUNCTUATION
IntlChar::LB_COMBINING_MARK
IntlChar::LB_CARRIAGE_RETURN
IntlChar::LB_EXCLAMATION
IntlChar::LB_GLUE
IntlChar::LB_HYPHEN
IntlChar::LB_IDEOGRAPHIC
IntlChar::LB_INSEPARABLE
IntlChar::LB_INSEPERABLE
IntlChar::LB_INFIX_NUMERIC
IntlChar::LB_LINE_FEED
IntlChar::LB_NONSTARTER
IntlChar::LB_NUMERIC
IntlChar::LB_OPEN_PUNCTUATION
IntlChar::LB_POSTFIX_NUMERIC
IntlChar::LB_PREFIX_NUMERIC
IntlChar::LB_QUOTATION
IntlChar::LB_COMPLEX_CONTEXT
IntlChar::LB_SURROGATE
IntlChar::LB_SPACE
IntlChar::LB_BREAK_SYMBOLS
IntlChar::LB_ZWSPACE
IntlChar::LB_NEXT_LINE
IntlChar::LB_WORD_JOINER
IntlChar::LB_H2
IntlChar::LB_H3
IntlChar::LB_JL
IntlChar::LB_JT
IntlChar::LB_JV
IntlChar::LB_CLOSE_PARENTHESIS
IntlChar::LB_CONDITIONAL_JAPANESE_STARTER
IntlChar::LB_HEBREW_LETTER
IntlChar::LB_REGIONAL_INDICATOR
IntlChar::LB_COUNT
IntlChar::NT_NONE
IntlChar::NT_DECIMAL
IntlChar::NT_DIGIT
IntlChar::NT_NUMERIC
IntlChar::NT_COUNT
IntlChar::HST_NOT_APPLICABLE
IntlChar::HST_LEADING_JAMO
IntlChar::HST_VOWEL_JAMO
IntlChar::HST_TRAILING_JAMO
IntlChar::HST_LV_SYLLABLE
IntlChar::HST_LVT_SYLLABLE
IntlChar::HST_COUNT
IntlChar::FOLD_CASE_DEFAULT
IntlChar::FOLD_CASE_EXCLUDE_SPECIAL_I
更新日志
版本 | 说明 |
---|---|
7.0.6 | The IntlChar::NO_NUMERIC_VALUE constant was added. |
IntlChar::charAge
Get the "age" of the code point
说明
public <span
class="modifier">static array <span
class="methodname">IntlChar::charAge ( <span
class="methodparam">mixed $codepoint
)
Gets the "age" of the code point.
The "age" is the Unicode version when the code point was first designated (as a non-character or for Private Use) or assigned a character. This can be useful to avoid emitting code points to receiving processes that do not accept newer characters.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
The Unicode version number, as an array. For example, version 1.3.31.2 would be represented as [1, 3, 31, 2].
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::charage("\u{2603}"));
var_dump(IntlChar::charage("\u{1F576}"));
?>
以上例程会输出:
array(4) {
[0]=>
int(1)
[1]=>
int(1)
[2]=>
int(0)
[3]=>
int(0)
}
array(4) {
[0]=>
int(7)
[1]=>
int(0)
[2]=>
int(0)
[3]=>
int(0)
}
参见
- IntlChar::getUnicodeVersion
- IntlChar::getIntPropertyMinValue
- IntlChar::getIntPropertyValue
IntlChar::charDigitValue
Get the decimal digit value of a decimal digit character
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::charDigitValue ( <span
class="methodparam">mixed $codepoint
)
Returns the decimal digit value of a decimal digit character.
Such characters have the general category "Nd" (decimal digit numbers) and a Numeric_Type of Decimal.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
The decimal digit value of codepoint
, or -1 if it is not a decimal
digit character.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::charDigitValue("1"));
var_dump(IntlChar::charDigitValue("\u{0662}"));
var_dump(IntlChar::charDigitValue("\u{0E53}"));
?>
以上例程会输出:
int(1)
int(2)
int(3)
参见
- IntlChar::getNumericValue
IntlChar::charDirection
Get bidirectional category value for a code point
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::charDirection ( <span
class="methodparam">mixed $codepoint
)
Returns the bidirectional category value for the code point, which is used in the » Unicode bidirectional algorithm (UAX #9).
Note:
Some unassigned code points have bidi values of R or AL because they are in blocks that are reserved for Right-To-Left scripts.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
The bidirectional category value; one of the following constants:
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR
IntlChar::CHAR_DIRECTION_ARABIC_NUMBER
IntlChar::CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR
IntlChar::CHAR_DIRECTION_BLOCK_SEPARATOR
IntlChar::CHAR_DIRECTION_SEGMENT_SEPARATOR
IntlChar::CHAR_DIRECTION_WHITE_SPACE_NEUTRAL
IntlChar::CHAR_DIRECTION_OTHER_NEUTRAL
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE
IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT
IntlChar::CHAR_DIRECTION_DIR_NON_SPACING_MARK
IntlChar::CHAR_DIRECTION_BOUNDARY_NEUTRAL
IntlChar::CHAR_DIRECTION_FIRST_STRONG_ISOLATE
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE
IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE
IntlChar::CHAR_DIRECTION_CHAR_DIRECTION_COUNT
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::charDirection("A") === IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT);
var_dump(IntlChar::charDirection("\u{05E9}") === IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT);
var_dump(IntlChar::charDirection("+") === IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR);
var_dump(IntlChar::charDirection(".") === IntlChar::CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR);
?>
以上例程会输出:
bool(true)
bool(true)
bool(true)
bool(true)
IntlChar::charFromName
Find Unicode character by name and return its code point value
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::charFromName ( <span
class="methodparam">string
$characterName
[, <span
class="type">int $nameChoice
=
IntlChar::UNICODE_CHAR_NAME
] )
Finds a Unicode character by its name and returns its code point value.
The name is matched exactly and completely. If the name does not
correspond to a code point, null
is returned.
A Unicode 1.0 name is matched only if it differs from the modern name. Unicode names are all uppercase. Extended names are lowercase followed by an uppercase hexadecimal number, and within angle brackets.
参数
characterName
Full name of the Unicode character.
nameChoice
Which set of names to use for the lookup. Can be any of these constants:
IntlChar::UNICODE_CHAR_NAME
(default)IntlChar::UNICODE_10_CHAR_NAME
IntlChar::EXTENDED_CHAR_NAME
IntlChar::CHAR_NAME_ALIAS
IntlChar::CHAR_NAME_CHOICE_COUNT
返回值
The Unicode value of the code point with the given name (as an <span
class="type">int), or null
if there is no such code point.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::charFromName("LATIN CAPITAL LETTER A"));
var_dump(IntlChar::charFromName("SNOWMAN"));
var_dump(IntlChar::charFromName("RECYCLING SYMBOL FOR TYPE-1 PLASTICS"));
var_dump(IntlChar::charFromName("A RANDOM STRING WHICH DOESN'T CORRESPOND TO ANY UNICODE CHARACTER"));
?>
以上例程会输出:
int(65)
int(9731)
int(9843)
bool(false)
参见
- IntlChar::charName
- IntlChar::enumCharNames
IntlChar::charMirror
Get the "mirror-image" character for a code point
说明
public <span
class="modifier">static mixed <span
class="methodname">IntlChar::charMirror ( <span
class="methodparam">mixed $codepoint
)
Maps the specified character to a "mirror-image" character.
For characters with the Bidi_Mirrored property, implementations sometimes need a "poor man's" mapping to another Unicode character (code point) such that the default glyph may serve as the mirror-image of the default glyph of the specified character. This is useful for text conversion to and from codepages with visual order, and for displays without glyph selection capabilities.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns another Unicode code point that may serve as a mirror-image
substitute, or codepoint
itself if there is no such mapping or
codepoint
does not have the Bidi_Mirrored property.
The return type will be int unless the code point was passed as a UTF-8 string, in which case a string will be returned.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::charMirror("A"));
var_dump(IntlChar::charMirror("<"));
var_dump(IntlChar::charMirror("("));
?>
以上例程会输出:
string(1) "A"
string(1) ">"
string(2) ")"
参见
- IntlChar::isMirrored
IntlChar::PROPERTY_BIDI_MIRRORED
IntlChar::charName
Retrieve the name of a Unicode character
说明
public <span
class="modifier">static string <span
class="methodname">IntlChar::charName ( <span
class="methodparam">mixed $codepoint
[, int
$nameChoice
=
IntlChar::UNICODE_CHAR_NAME
] )
Retrieves the name of a Unicode character.
Depending on nameChoice
, the resulting character name is the "modern"
name or the name that was defined in Unicode version 1.0. The name
contains only "invariant" characters like A-Z, 0-9, space, and '-'.
Unicode 1.0 names are only retrieved if they are different from the
modern names and if ICU contains the data for them.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
nameChoice
Which set of names to use for the lookup. Can be any of these constants:
IntlChar::UNICODE_CHAR_NAME
(default)IntlChar::UNICODE_10_CHAR_NAME
IntlChar::EXTENDED_CHAR_NAME
IntlChar::CHAR_NAME_ALIAS
IntlChar::CHAR_NAME_CHOICE_COUNT
返回值
The corresponding name, or an empty string if there is no name for this
character, or null
if there is no such code point.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::charName("."));
var_dump(IntlChar::charName(".", IntlChar::UNICODE_CHAR_NAME));
var_dump(IntlChar::charName("\u{2603}"));
var_dump(IntlChar::charName("\u{0000}"));
?>
以上例程会输出:
string(9) "FULL STOP"
string(9) "FULL STOP"
string(7) "SNOWMAN"
string(0) ""
参见
- IntlChar::charFromName
- IntlChar::enumCharNames
IntlChar::charType
Get the general category value for a code point
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::charType ( <span
class="methodparam">mixed $codepoint
)
Returns the general category value for the code point.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns the general category type, which may be one of the following constants:
IntlChar::CHAR_CATEGORY_UNASSIGNED
IntlChar::CHAR_CATEGORY_GENERAL_OTHER_TYPES
IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER
IntlChar::CHAR_CATEGORY_LOWERCASE_LETTER
IntlChar::CHAR_CATEGORY_TITLECASE_LETTER
IntlChar::CHAR_CATEGORY_MODIFIER_LETTER
IntlChar::CHAR_CATEGORY_OTHER_LETTER
IntlChar::CHAR_CATEGORY_NON_SPACING_MARK
IntlChar::CHAR_CATEGORY_ENCLOSING_MARK
IntlChar::CHAR_CATEGORY_COMBINING_SPACING_MARK
IntlChar::CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER
IntlChar::CHAR_CATEGORY_LETTER_NUMBER
IntlChar::CHAR_CATEGORY_OTHER_NUMBER
IntlChar::CHAR_CATEGORY_SPACE_SEPARATOR
IntlChar::CHAR_CATEGORY_LINE_SEPARATOR
IntlChar::CHAR_CATEGORY_PARAGRAPH_SEPARATOR
IntlChar::CHAR_CATEGORY_CONTROL_CHAR
IntlChar::CHAR_CATEGORY_FORMAT_CHAR
IntlChar::CHAR_CATEGORY_PRIVATE_USE_CHAR
IntlChar::CHAR_CATEGORY_SURROGATE
IntlChar::CHAR_CATEGORY_DASH_PUNCTUATION
IntlChar::CHAR_CATEGORY_START_PUNCTUATION
IntlChar::CHAR_CATEGORY_END_PUNCTUATION
IntlChar::CHAR_CATEGORY_CONNECTOR_PUNCTUATION
IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION
IntlChar::CHAR_CATEGORY_MATH_SYMBOL
IntlChar::CHAR_CATEGORY_CURRENCY_SYMBOL
IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL
IntlChar::CHAR_CATEGORY_OTHER_SYMBOL
IntlChar::CHAR_CATEGORY_INITIAL_PUNCTUATION
IntlChar::CHAR_CATEGORY_FINAL_PUNCTUATION
IntlChar::CHAR_CATEGORY_CHAR_CATEGORY_COUNT
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::charType("A") === IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER);
var_dump(IntlChar::charType(".") === IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION);
var_dump(IntlChar::charType("\t") === IntlChar::CHAR_CATEGORY_CONTROL_CHAR);
var_dump(IntlChar::charType("\u{2603}") === IntlChar::CHAR_CATEGORY_OTHER_SYMBOL);
?>
以上例程会输出:
bool(true)
bool(true)
bool(true)
bool(true)
IntlChar::chr
Return Unicode character by code point value
说明
public <span
class="modifier">static string <span
class="methodname">IntlChar::chr ( <span
class="methodparam">mixed $codepoint
)
Returns a string containing the character specified by the Unicode code point value.
This function compliments IntlChar::ord.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
A string containing the single character specified by the Unicode code point value.
范例
示例 #1 Testing different code points
<?php
$values = ["A", 63, 123, 9731];
foreach ($values as $value) {
var_dump(IntlChar::chr($value));
}
?>
以上例程会输出:
string(1) "A"
string(1) "?"
string(1) "{"
string(3) "☃"
参见
- IntlChar::ord
- chr
IntlChar::digit
Get the decimal digit value of a code point for a given radix
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::digit ( <span
class="methodparam">string $codepoint
[, int
$radix
= 10 ] )
Returns the decimal digit value of the code point in the specified radix.
If the radix is not in the range 2\<=radix\<=36 or if the value of
codepoint
is not a valid digit in the specified radix, false
is
returned. A character is a valid digit if at least one of the following
is true:
- The character has a decimal digit value. Such characters have the general category "Nd" (decimal digit numbers) and a Numeric_Type of Decimal. In this case the value is the character's decimal digit value.
- The character is one of the uppercase Latin letters 'A' through 'Z'. In this case the value is c-'A'+10.
- The character is one of the lowercase Latin letters 'a' through 'z'. In this case the value is ch-'a'+10.
- Latin letters from both the ASCII range (0061..007A, 0041..005A) as well as from the Fullwidth ASCII range (FF41..FF5A, FF21..FF3A) are recognized.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
radix
The radix (defaults to 10).
返回值
Returns the numeric value represented by the character in the specified
radix, or false
if there is no value or if the value exceeds the
radix.
Warning
此函数可能返回布尔值 false
,但也可能返回等同于 false
的非布尔值。请阅读
布尔类型章节以获取更多信息。应使用
=== 运算符来测试此函数的返回值。
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::digit("0"));
var_dump(IntlChar::digit("3"));
var_dump(IntlChar::digit("A"));
var_dump(IntlChar::digit("A", 16));
?>
以上例程会输出:
int(0)
int(3)
bool(false)
int(10)
参见
- IntlChar::forDigit
- IntlChar::charDigitValue
- IntlChar::isdigit
IntlChar::PROPERTY_NUMERIC_TYPE
IntlChar::enumCharNames
Enumerate all assigned Unicode characters within a range
说明
public <span
class="modifier">static void <span
class="methodname">IntlChar::enumCharNames ( <span
class="methodparam">mixed $start
,
mixed
$limit
, <span
class="type">callable $callback
[, <span
class="methodparam">int $nameChoice
<span
class="initializer"> = IntlChar::UNICODE_CHAR_NAME
] )
Enumerate all assigned Unicode characters between the start and limit code points (start inclusive, limit exclusive) and call a function for each, passing the code point value and the character name.
For Unicode 1.0 names, only those are enumerated that differ from the modern names.
参数
start
The first code point in the enumeration range.
limit
One more than the last code point in the enumeration range (the first
one after the range).
callback
The function that is to be called for each character name. The following
three arguments will be passed into it:
- int $codepoint - The numeric code point value
- int $nameChoice - The same value as the
nameChoice
parameter below - string $name - The name of the character
nameChoice
Selector for which kind of names to enumerate. Can be any of these
constants:
IntlChar::UNICODE_CHAR_NAME
(default)IntlChar::UNICODE_10_CHAR_NAME
IntlChar::EXTENDED_CHAR_NAME
IntlChar::CHAR_NAME_ALIAS
IntlChar::CHAR_NAME_CHOICE_COUNT
返回值
没有返回值。
范例
示例 #1 Enumerating over a sample range of code points
<?php
IntlChar::enumCharNames(0x2600, 0x2610, function($codepoint, $nameChoice, $name) {
printf("U+%04x %s\n", $codepoint, $name);
});
?>
以上例程会输出:
U+2600 BLACK SUN WITH RAYS
U+2601 CLOUD
U+2602 UMBRELLA
U+2603 SNOWMAN
U+2604 COMET
U+2605 BLACK STAR
U+2606 WHITE STAR
U+2607 LIGHTNING
U+2608 THUNDERSTORM
U+2609 SUN
U+260a ASCENDING NODE
U+260b DESCENDING NODE
U+260c CONJUNCTION
U+260d OPPOSITION
U+260e BLACK TELEPHONE
U+260f WHITE TELEPHONE
参见
- IntlChar::charName
- IntlChar::charFromName
IntlChar::enumCharTypes
Enumerate all code points with their Unicode general categories
说明
public <span
class="modifier">static void <span
class="methodname">IntlChar::enumCharTypes ( <span
class="methodparam">callable
$callback
)
Enumerates efficiently all code points with their Unicode general categories. This is useful for building data structures, for enumerating all assigned code points, etc.
For each contiguous range of code points with a given general category
("character type"), the callback
function is called. Adjacent ranges
have different types. The Unicode Standard guarantees that the numeric
value of the type is 0..31.
参数
callback
The function that is to be called for each contiguous range of code
points with the same general category. The following three arguments
will be passed into it:
- int $start - The starting code point of the range
- int $end - The ending code point of the range
- int $name - The category type (one of the IntlChar::CHAR_CATEGORY_* constants)
返回值
没有返回值。
范例
示例 #1 Enumerating over a sample range of code points
<?php
IntlChar::enumCharTypes(function($start, $end, $type) {
printf("U+%04x through U+%04x are in category %d\n", $start, $end, $type);
});
?>
以上例程会输出:
U+0000 through U+0020 are in category 15
U+0020 through U+0021 are in category 12
U+0021 through U+0024 are in category 23
U+0024 through U+0025 are in category 25
U+0025 through U+0028 are in category 23
U+0028 through U+0029 are in category 20
U+0029 through U+002a are in category 21
U+002a through U+002b are in category 23
U+002b through U+002c are in category 24
U+002c through U+002d are in category 23
U+002d through U+002e are in category 19
U+002e through U+0030 are in category 23
U+0030 through U+003a are in category 9
...
IntlChar::foldCase
Perform case folding on a code point
说明
public <span
class="modifier">static mixed <span
class="methodname">IntlChar::foldCase ( <span
class="methodparam">mixed $codepoint
[, int
$options
=
IntlChar::FOLD_CASE_DEFAULT
] )
The given character is mapped to its case folding equivalent; if the character has no case folding equivalent, the character itself is returned.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
options
Either IntlChar::FOLD_CASE_DEFAULT
(default) or
IntlChar::FOLD_CASE_EXCLUDE_SPECIAL_I
.
返回值
Returns the Simple_Case_Folding of the code point, if any; otherwise the code point itself.
IntlChar::forDigit
Get character representation for a given digit and radix
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::forDigit ( <span
class="methodparam">int $digit
[,
int $radix
<span
class="initializer"> = 10 ] )
Determines the character representation for a specific digit in the specified radix.
If the value of radix is not a valid radix, or the value of digit is not a valid digit in the specified radix, the null character (U+0000) is returned.
The radix argument is valid if it is greater than or equal to 2 and less than or equal to 36. The digit argument is valid if 0 \<= digit \< radix.
If the digit is less than 10, then '0' + digit is returned. Otherwise, the value 'a' + digit - 10 is returned.
参数
digit
The number to convert to a character.
radix
The radix (defaults to 10).
返回值
The character representation (as a string) of the specified digit in the specified radix.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::forDigit(0));
var_dump(IntlChar::forDigit(3));
var_dump(IntlChar::forDigit(3, 10));
var_dump(IntlChar::forDigit(10));
var_dump(IntlChar::forDigit(10, 16));
?>
以上例程会输出:
int(48)
int(51)
int(51)
int(0)
int(97)
参见
- IntlChar::digit
- IntlChar::charDigitValue
- IntlChar::isdigit
IntlChar::PROPERTY_NUMERIC_TYPE
IntlChar::getBidiPairedBracket
Get the paired bracket character for a code point
说明
public <span
class="modifier">static mixed <span
class="methodname">IntlChar::getBidiPairedBracket ( <span
class="methodparam">mixed $codepoint
)
Maps the specified character to its paired bracket character.
For Bidi_Paired_Bracket_Type!=None, this is the same as <span
class="function">IntlChar::charMirror. Otherwise codepoint
itself is returned.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns the paired bracket code point, or codepoint
itself if there is
no such mapping.
The return type will be int unless the code point was passed as a UTF-8 string, in which case a string will be returned.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::getBidiPairedBracket(91));
var_dump(IntlChar::getBidiPairedBracket('['));
?>
以上例程会输出:
int(93)
string(1) "]"
参见
- IntlChar::charMirror
IntlChar::PROPERTY_BIDI_PAIRED_BRACKET
IntlChar::PROPERTY_BIDI_PAIRED_BRACKET_TYPE
IntlChar::getBlockCode
Get the Unicode allocation block containing a code point
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::getBlockCode ( <span
class="methodparam">mixed $codepoint
)
Returns the Unicode allocation block that contains the character.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns the block value for codepoint
. See the
IntlChar::BLOCK_CODE_* constants for possible return values.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::getBlockCode("A") === IntlChar::BLOCK_CODE_BASIC_LATIN);
var_dump(IntlChar::getBlockCode("Φ") === IntlChar::BLOCK_CODE_GREEK);
var_dump(IntlChar::getBlockCode("\u{2603}") === IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS);
?>
以上例程会输出:
bool(true)
bool(true)
bool(true)
IntlChar::getCombiningClass
Get the combining class of a code point
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::getCombiningClass ( <span
class="methodparam">mixed $codepoint
)
Returns the combining class of the code point.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns the combining class of the character.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::getCombiningClass("A"));
var_dump(IntlChar::getCombiningClass("\u{0334}"));
var_dump(IntlChar::getCombiningClass("\u{0358}"));
?>
以上例程会输出:
int(0)
int(1)
int(232)
IntlChar::getFC_NFKC_Closure
Get the FC_NFKC_Closure property for a code point
说明
public <span
class="modifier">static string <span
class="methodname">IntlChar::getFC_NFKC_Closure ( <span
class="methodparam">mixed $codepoint
)
Gets the FC_NFKC_Closure property string for a character.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns the FC_NFKC_Closure property string for the codepoint
, or an
empty string if there is none.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::getFC_NFKC_Closure("\u{2121}"));
var_dump(IntlChar::getFC_NFKC_Closure("\u{1D2D}"));
?>
以上例程会输出:
string(3) "tel"
string(2) "æ"
IntlChar::getIntPropertyMaxValue
Get the max value for a Unicode property
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::getIntPropertyMaxValue ( <span
class="methodparam">int $property
)
Gets the maximum value for an enumerated/integer/binary Unicode property.
参数
property
The Unicode property to lookup (see the IntlChar::PROPERTY_*
constants).
返回值
The maximum value returned by <span class="function">IntlChar::getIntPropertyValue for a Unicode property. \<=0 if the property selector is out of range.
范例
示例 #1 Testing different properties
<?php
var_dump(IntlChar::getIntPropertyMaxValue(IntlChar::PROPERTY_BIDI_CLASS));
var_dump(IntlChar::getIntPropertyMaxValue(IntlChar::PROPERTY_SCRIPT));
var_dump(IntlChar::getIntPropertyMaxValue(IntlChar::PROPERTY_IDEOGRAPHIC));
var_dump(IntlChar::getIntPropertyMaxValue(999999999)); // Some made-up value
?>
以上例程会输出:
int(22)
int(166)
int(1)
int(-1)
参见
- IntlChar::hasBinaryProperty
- IntlChar::getIntPropertyMinValue
- IntlChar::getIntPropertyValue
- IntlChar::getUnicodeVersion
IntlChar::getIntPropertyMinValue
Get the min value for a Unicode property
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::getIntPropertyMinValue ( <span
class="methodparam">int $property
)
Gets the minimum value for an enumerated/integer/binary Unicode property.
参数
property
The Unicode property to lookup (see the IntlChar::PROPERTY_*
constants).
返回值
The minimum value returned by <span class="function">IntlChar::getIntPropertyValue for a Unicode property. 0 if the property selector is out of range.
范例
示例 #1 Testing different properties
<?php
var_dump(IntlChar::getIntPropertyMinValue(IntlChar::PROPERTY_BIDI_CLASS));
var_dump(IntlChar::getIntPropertyMinValue(IntlChar::PROPERTY_SCRIPT));
var_dump(IntlChar::getIntPropertyMinValue(IntlChar::PROPERTY_IDEOGRAPHIC));
var_dump(IntlChar::getIntPropertyMinValue(999999999)); // Some made-up value
?>
以上例程会输出:
int(0)
int(0)
int(0)
int(0)
参见
- IntlChar::hasBinaryProperty
- IntlChar::getIntPropertyMaxValue
- IntlChar::getIntPropertyValue
- IntlChar::getUnicodeVersion
IntlChar::getIntPropertyValue
Get the value for a Unicode property for a code point
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::getIntPropertyValue ( <span
class="methodparam">mixed $codepoint
, int
$property
)
Gets the property value for an enumerated or integer Unicode property for a code point. Also returns binary and mask property values.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
property
The Unicode property to lookup (see the IntlChar::PROPERTY_*
constants).
返回值
Returns the numeric value that is directly the property value or, for enumerated properties, corresponds to the numeric value of the enumerated constant of the respective property value enumeration type.
Returns 0 or 1 (for false
/true
) for binary Unicode
properties.
Returns a bit-mask for mask properties.
Returns 0 if property
is out of bounds or if the Unicode version
does not have data for the property at all, or not for this code point.
范例
示例 #1 Testing different properties
<?php
var_dump(IntlChar::getIntPropertyValue("A", IntlChar::PROPERTY_ALPHABETIC) === 1);
var_dump(IntlChar::getIntPropertyValue("[", IntlChar::PROPERTY_BIDI_MIRRORED) === 1);
var_dump(IntlChar::getIntPropertyValue("Φ", IntlChar::PROPERTY_BLOCK) === IntlChar::BLOCK_CODE_GREEK);
?>
以上例程会输出:
bool(true)
bool(true)
bool(true)
参见
- IntlChar::hasBinaryProperty
- IntlChar::getIntPropertyMinValue
- IntlChar::getIntPropertyMaxValue
- IntlChar::getUnicodeVersion
IntlChar::getNumericValue
Get the numeric value for a Unicode code point
说明
public <span
class="modifier">static float <span
class="methodname">IntlChar::getNumericValue ( <span
class="methodparam">mixed $codepoint
)
Gets the numeric value for a Unicode code point as defined in the Unicode Character Database.
For characters without any numeric values in the Unicode Character
Database, this function will return IntlChar::NO_NUMERIC_VALUE
.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Numeric value of codepoint
, or IntlChar::NO_NUMERIC_VALUE
if
none is defined. This constant was added in PHP 7.0.6, prior to this
version the literal value (float)-123456789
may be used instead.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::getNumericValue("4"));
var_dump(IntlChar::getNumericValue("x"));
var_dump(IntlChar::getNumericValue("\u{216C}"));
?>
以上例程会输出:
float(4)
float(-123456789)
float(50)
IntlChar::getPropertyEnum
Get the property constant value for a given property name
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::getPropertyEnum ( <span
class="methodparam">string $alias
)
Returns the property constant value for a given property name, as specified in the Unicode database file PropertyAliases.txt. Short, long, and any other variants are recognized.
In addition, this function maps the synthetic names "gcm" /
"General_Category_Mask" to the property
IntlChar::PROPERTY_GENERAL_CATEGORY_MASK
. These names are not in
PropertyAliases.txt.
This function compliments <span class="function">IntlChar::getPropertyName.
参数
alias
The property name to be matched. The name is compared using "loose
matching" as described in PropertyAliases.txt.
返回值
Returns an IntlChar::PROPERTY_ constant value, or
IntlChar::PROPERTY_INVALID_CODE
if the given name does not match
any property.
范例
示例 #1 Testing different properties
<?php
var_dump(IntlChar::getPropertyEnum('Bidi_Class') === IntlChar::PROPERTY_BIDI_CLASS);
var_dump(IntlChar::getPropertyEnum('script') === IntlChar::PROPERTY_SCRIPT);
var_dump(IntlChar::getPropertyEnum('IDEOGRAPHIC') === IntlChar::PROPERTY_IDEOGRAPHIC);
var_dump(IntlChar::getPropertyEnum('Some made-up string') === IntlChar::PROPERTY_INVALID_CODE);
?>
以上例程会输出:
bool(true)
bool(true)
bool(true)
bool(true)
参见
- IntlChar::getPropertyName
IntlChar::getPropertyName
Get the Unicode name for a property
说明
public <span
class="modifier">static string <span
class="methodname">IntlChar::getPropertyName ( <span
class="methodparam">int $property
[,
int
$nameChoice
=
IntlChar::LONG_PROPERTY_NAME
] )
Returns the Unicode name for a given property, as given in the Unicode database file PropertyAliases.txt.
In addition, this function maps the property
IntlChar::PROPERTY_GENERAL_CATEGORY_MASK
to the synthetic names
"gcm" / "General_Category_Mask". These names are not in
PropertyAliases.txt.
This function compliments <span class="function">IntlChar::getPropertyEnum.
参数
property
The Unicode property to lookup (see the IntlChar::PROPERTY_*
constants).
IntlChar::PROPERTY_INVALID_CODE
should not be used. Also, if
property
is out of range, false
is returned.
nameChoice
Selector for which name to get. If out of range, false
is
returned.
All properties have a long name. Most have a short name, but some do
not. Unicode allows for additional names; if present these will be
returned by adding 1, 2, etc. to IntlChar::LONG_PROPERTY_NAME
.
返回值
Returns the name, or false
if either the property
or the
nameChoice
is out of range.
If a given nameChoice
returns false
, then all larger values of
nameChoice
will return false
, with one exception: if false
is returned for IntlChar::SHORT_PROPERTY_NAME
, then
IntlChar::LONG_PROPERTY_NAME
(and higher) may still return a
non-false
value.
范例
示例 #1 Testing different properties
<?php
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_CLASS));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_CLASS, IntlChar::SHORT_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_CLASS, IntlChar::LONG_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_CLASS, IntlChar::LONG_PROPERTY_NAME + 1));
?>
以上例程会输出:
string(10) "Bidi_Class"
string(2) "bc"
string(10) "Bidi_Class"
bool(false)
参见
- IntlChar::getPropertyEnum
IntlChar::getPropertyValueEnum
Get the property value for a given value name
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::getPropertyValueEnum ( <span
class="methodparam">int $property
,
string
$name
)
Returns the property value integer for a given value name, as specified in the Unicode database file PropertyValueAliases.txt. Short, long, and any other variants are recognized.
Note:
Some of the names in PropertyValueAliases.txt will only be recognized with
IntlChar::PROPERTY_GENERAL_CATEGORY_MASK
, notIntlChar::PROPERTY_GENERAL_CATEGORY
. These include:
- "C" / "Other"
- "L" / "Letter"
- "LC" / "Cased_Letter"
- "M" / "Mark"
- "N" / "Number"
- "P" / "Punctuation"
- "S" / "Symbol"
- "Z" / "Separator"
参数
property
The Unicode property to lookup (see the IntlChar::PROPERTY_*
constants).
If out of range, or this method doesn't work with the given value,
IntlChar::PROPERTY_INVALID_CODE
is returned.
name
The value name to be matched. The name is compared using "loose
matching" as described in PropertyValueAliases.txt.
返回值
Returns the corresponding value integer, or
IntlChar::PROPERTY_INVALID_CODE
if the given name does not match
any value of the given property, or if the property is invalid.
范例
示例 #1 Testing different properties
<?php
var_dump(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BLOCK, 'greek') === IntlChar::BLOCK_CODE_GREEK);
var_dump(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BIDI_CLASS, 'RIGHT_TO_LEFT') === IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT);
var_dump(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BIDI_CLASS, 'some made-up string') === IntlChar::PROPERTY_INVALID_CODE);
var_dump(IntlChar::getPropertyValueEnum(123456789, 'RIGHT_TO_LEFT') === IntlChar::PROPERTY_INVALID_CODE);
?>
以上例程会输出:
bool(true)
bool(true)
bool(true)
bool(true)
IntlChar::getPropertyValueName
Get the Unicode name for a property value
说明
public <span
class="modifier">static string <span
class="methodname">IntlChar::getPropertyValueName ( <span
class="methodparam">int $property
,
int $value
[, int
$nameChoice
=
IntlChar::LONG_PROPERTY_NAME
] )
Returns the Unicode name for a given property value, as given in the Unicode database file PropertyValueAliases.txt.
Note:
Some of the names in PropertyValueAliases.txt can only be retrieved using
IntlChar::PROPERTY_GENERAL_CATEGORY_MASK
, notIntlChar::PROPERTY_GENERAL_CATEGORY
. These include:
- "C" / "Other"
- "L" / "Letter"
- "LC" / "Cased_Letter"
- "M" / "Mark"
- "N" / "Number"
- "P" / "Punctuation"
- "S" / "Symbol"
- "Z" / "Separator"
参数
property
The Unicode property to lookup (see the IntlChar::PROPERTY_*
constants).
If out of range, or this method doesn't work with the given value,
false
is returned.
value
Selector for a value for the given property. If out of range,
false
is returned.
In general, valid values range from 0 up to some maximum. There are a couple exceptions:
IntlChar::PROPERTY_BLOCK
values begin at the non-zero valueIntlChar::BLOCK_CODE_BASIC_LATIN
IntlChar::PROPERTY_CANONICAL_COMBINING_CLASS
values are not contiguous and range from 0..240.
nameChoice
Selector for which name to get. If out of range, false
is
returned.
All values have a long name. Most have a short name, but some do not.
Unicode allows for additional names; if present these will be returned
by adding 1, 2, etc. to IntlChar::LONG_PROPERTY_NAME
.
返回值
Returns the name, or false
if either the property
or the
nameChoice
is out of range.
If a given nameChoice
returns false
, then all larger values of
nameChoice
will return false
, with one exception: if false
is returned for IntlChar::SHORT_PROPERTY_NAME
, then
IntlChar::LONG_PROPERTY_NAME
(and higher) may still return a
non-false
value.
范例
示例 #1 Testing different properties
<?php
var_dump(IntlChar::getPropertyValueName(IntlChar::PROPERTY_BLOCK, IntlChar::BLOCK_CODE_GREEK));
var_dump(IntlChar::getPropertyValueName(IntlChar::PROPERTY_BLOCK, IntlChar::BLOCK_CODE_GREEK, IntlChar::SHORT_PROPERTY_NAME));
var_dump(IntlChar::getPropertyValueName(IntlChar::PROPERTY_BLOCK, IntlChar::BLOCK_CODE_GREEK, IntlChar::LONG_PROPERTY_NAME));
var_dump(IntlChar::getPropertyValueName(IntlChar::PROPERTY_BLOCK, IntlChar::BLOCK_CODE_GREEK, IntlChar::LONG_PROPERTY_NAME + 1));
?>
以上例程会输出:
string(16) "Greek_And_Coptic"
string(5) "Greek"
string(16) "Greek_And_Coptic"
bool(false)
IntlChar::getUnicodeVersion
Get the Unicode version
说明
public <span class="modifier">static array <span class="methodname">IntlChar::getUnicodeVersion ( <span class="methodparam">void )
Gets the Unicode version information.
The version array is filled in with the version information for the Unicode standard that is currently used by ICU. For example, Unicode version 3.1.1 is represented as an array with the values [3, 1, 1, 0].
参数
此函数没有参数。
返回值
An array containing the Unicode version number.
范例
示例 #1 Testing different properties
<?php
var_dump(IntlChar::getUnicodeVersion());
?>
以上例程会输出:
array(4) {
[0]=>
int(7)
[1]=>
int(0)
[2]=>
int(0)
[3]=>
int(0)
}
参见
- IntlChar::charAge
IntlChar::hasBinaryProperty
Check a binary Unicode property for a code point
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::hasBinaryProperty ( <span
class="methodparam">mixed $codepoint
, int
$property
)
Checks a binary Unicode property for a code point.
Unicode, especially in version 3.2, defines many more properties than the original set in UnicodeData.txt.
The properties APIs are intended to reflect Unicode properties as defined in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR). For details about the properties see » http://www.unicode.org/ucd/. For names of Unicode properties see the UCD file PropertyAliases.txt.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
property
The Unicode property to lookup (see the IntlChar::PROPERTY_*
constants).
返回值
Returns true
or false
according to the binary Unicode
property value for codepoint
. Also false
if property
is out of
bounds or if the Unicode version does not have data for the property at
all, or not for this code point.
范例
示例 #1 Testing different properties
<?php
var_dump(IntlChar::hasBinaryProperty("A", IntlChar::PROPERTY_ALPHABETIC));
var_dump(IntlChar::hasBinaryProperty("A", IntlChar::PROPERTY_CASE_SENSITIVE));
var_dump(IntlChar::hasBinaryProperty("A", IntlChar::PROPERTY_BIDI_MIRRORED));
var_dump(IntlChar::hasBinaryProperty("[", IntlChar::PROPERTY_ALPHABETIC));
var_dump(IntlChar::hasBinaryProperty("[", IntlChar::PROPERTY_CASE_SENSITIVE));
var_dump(IntlChar::hasBinaryProperty("[", IntlChar::PROPERTY_BIDI_MIRRORED));
?>
以上例程会输出:
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
bool(true)
参见
- IntlChar::getIntPropertyValue
- IntlChar::getUnicodeVersion
IntlChar::isalnum
Check if code point is an alphanumeric character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isalnum ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is an alphanumeric character
(letter or digit). true
for characters with general categories "L"
(letters) and "Nd" (decimal digit numbers).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is an alphanumeric character,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isalnum("A"));
var_dump(IntlChar::isalnum("1"));
var_dump(IntlChar::isalnum("\u{2603}"));
?>
以上例程会输出:
bool(true)
bool(true)
bool(false)
参见
- IntlChar::isalpha
- IntlChar::isdigit
IntlChar::isalpha
Check if code point is a letter character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isalpha ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a letter character.
true
for general categories "L" (letters).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a letter character, false
if
not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isalpha("A"));
var_dump(IntlChar::isalpha("1"));
var_dump(IntlChar::isalpha("\u{2603}"));
?>
以上例程会输出:
bool(true)
bool(false)
bool(false)
参见
- IntlChar::isalnum
- IntlChar::isdigit
IntlChar::isbase
Check if code point is a base character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isbase ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a base character.
true
for general categories "L" (letters), "N" (numbers), "Mc"
(spacing combining marks), and "Me" (enclosing marks).
Note:
This is different from the Unicode definition in chapter 3.5, conformance clause D13, which defines base characters to be all characters (not Cn) that do not graphically combine with preceding characters (M) and that are neither control (Cc) or format (Cf) characters.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a base character, false
if
not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isbase("A"));
var_dump(IntlChar::isbase("1"));
var_dump(IntlChar::isbase("\u{2603}"));
?>
以上例程会输出:
bool(true)
bool(true)
bool(false)
参见
- IntlChar::isalpha
- IntlChar::isdigit
IntlChar::isblank
Check if code point is a "blank" or "horizontal space" character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isblank ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a "blank" or "horizontal space", a character that visibly separates words on a line.
The following are equivalent definitions:
true
for Unicode White_Space characters except for "vertical space controls" where "vertical space controls" are the following characters: U+000A (LF) U+000B (VT) U+000C (FF) U+000D (CR) U+0085 (NEL) U+2028 (LS) U+2029 (PS)true
for U+0009 (TAB) and characters with general category "Zs" (space separators) except Zero Width Space (ZWSP, U+200B).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is either a "blank" or "horizontal
space" character, false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isblank("A"));
var_dump(IntlChar::isblank(" "));
var_dump(IntlChar::isblank("\t"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(true)
参见
- IntlChar::isspace
- IntlChar::isJavaSpaceChar
- IntlChar::isUWhiteSpace
- IntlChar::isWhitespace
IntlChar::iscntrl
Check if code point is a control character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::iscntrl ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a control character.
A control character is one of the following:
- ISO 8-bit control character (U+0000..U+001f and U+007f..U+009f)
IntlChar::CHAR_CATEGORY_CONTROL_CHAR
(Cc)IntlChar::CHAR_CATEGORY_FORMAT_CHAR
(Cf)IntlChar::CHAR_CATEGORY_LINE_SEPARATOR
(Zl)IntlChar::CHAR_CATEGORY_PARAGRAPH_SEPARATOR
(Zp)
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a control character, false
if
not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::iscntrl("A"));
var_dump(IntlChar::iscntrl(" "));
var_dump(IntlChar::iscntrl("\n"));
var_dump(IntlChar::iscntrl("\u{200e}"));
?>
以上例程会输出:
bool(false)
bool(false)
bool(true)
bool(true)
参见
- IntlChar::isprint
IntlChar::PROPERTY_DEFAULT_IGNORABLE_CODE_POINT
IntlChar::isdefined
Check whether the code point is defined
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isdefined ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is "defined", which usually means that it is assigned a character.
true
for general categories other than "Cn" (other, not assigned).
Note:
Note that non-character code points (e.g., U+FDD0) are not "defined" (they are Cn), but surrogate code points are "defined" (Cs).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a defined character, false
if
not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isdefined("A"));
var_dump(IntlChar::isdefined(" "));
var_dump(IntlChar::isdefined("\u{FDD0}"));
?>
以上例程会输出:
bool(true)
bool(true)
bool(false)
参见
- IntlChar::isdigit
- IntlChar::isalpha
- IntlChar::isalnum
- IntlChar::isupper
- IntlChar::islower
- IntlChar::istitle
IntlChar::isdigit
Check if code point is a digit character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isdigit ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a digit character.
true
for characters with general category "Nd" (decimal digit
numbers). Beginning with Unicode 4, this is the same as testing for the
Numeric_Type of Decimal.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a digit character, false
if
not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isdigit("A"));
var_dump(IntlChar::isdigit("1"));
var_dump(IntlChar::isdigit("\t"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(false)
参见
- IntlChar::isalpha
- IntlChar::isalnum
- IntlChar::isxdigit
IntlChar::isgraph
Check if code point is a graphic character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isgraph ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a "graphic" character (printable, excluding spaces).
true
for all characters except those with general categories "Cc"
(control codes), "Cf" (format controls), "Cs" (surrogates), "Cn"
(unassigned), and "Z" (separators).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a "graphic" character, false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isgraph("A"));
var_dump(IntlChar::isgraph("1"));
var_dump(IntlChar::isgraph("\u{2603}"));
var_dump(IntlChar::isgraph("\n"));
?>
以上例程会输出:
bool(true)
bool(true)
bool(true)
bool(false)
IntlChar::isIDIgnorable
Check if code point is an ignorable character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isIDIgnorable ( <span
class="methodparam">mixed $codepoint
)
Determines if the specified character should be regarded as an ignorable character in an identifier.
true
for characters with general category "Cf" (format controls)
as well as non-whitespace ISO controls (U+0000..U+0008, U+000E..U+001B,
U+007F..U+009F).
Note:
Note that Unicode just recommends to ignore Cf (format controls).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is ignorable in identifiers,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isIDIgnorable("A"));
var_dump(IntlChar::isIDIgnorable(" "));
var_dump(IntlChar::isIDIgnorable("\u{007F}"));
?>
以上例程会输出:
bool(false)
bool(false)
bool(true)
参见
- IntlChar::isIDStart
- IntlChar::isIDPart
IntlChar::PROPERTY_DEFAULT_IGNORABLE_CODE_POINT
IntlChar::isIDPart
Check if code point is permissible in an identifier
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isIDPart ( <span
class="methodparam">mixed $codepoint
)
Determines if the specified character is permissible in an identifier.
true
for characters with general categories "L" (letters), "Nl"
(letter numbers), "Nd" (decimal digits), "Mc" and "Mn" (combining
marks), "Pc" (connecting punctuation), and u_isIDIgnorable(c).
Note:
This is almost the same as Unicode's ID_Continue (
IntlChar::PROPERTY_ID_CONTINUE
) except that Unicode recommends to ignore Cf which is less than <span class="function">IntlChar::isIDIgnorable.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is the code point may occur in an
identifier, false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isIDPart("A"));
var_dump(IntlChar::isIDPart("$"));
var_dump(IntlChar::isIDPart("\n"));
var_dump(IntlChar::isIDPart("\u{2603}"));
?>
以上例程会输出:
bool(true)
bool(false)
bool(false)
bool(false)
参见
- IntlChar::isIDIgnorable
- IntlChar::isIDStart
IntlChar::PROPERTY_ID_CONTINUE
IntlChar::isIDStart
Check if code point is permissible as the first character in an identifier
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isIDStart ( <span
class="methodparam">mixed $codepoint
)
Determines if the specified character is permissible as the first character in an identifier according to Unicode (The Unicode Standard, Version 3.0, chapter 5.16 Identifiers).
true
for characters with general categories "L" (letters) and "Nl"
(letter numbers).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
may start an identifier, false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isIDStart("A"));
var_dump(IntlChar::isIDStart("$"));
var_dump(IntlChar::isIDStart("\n"));
var_dump(IntlChar::isIDStart("\u{2603}"));
?>
以上例程会输出:
bool(true)
bool(false)
bool(false)
bool(false)
参见
- IntlChar::isalpha
- IntlChar::isIDPart
IntlChar::PROPERTY_ID_START
IntlChar::isISOControl
Check if code point is an ISO control code
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isISOControl ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is an ISO control code.
true
for U+0000..U+001f and U+007f..U+009f (general category
"Cc").
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is an ISO control code, false
if
not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isISOControl(" "));
var_dump(IntlChar::isISOControl("\n"));
var_dump(IntlChar::isISOControl("\u{200e}"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(false)
参见
- IntlChar::iscntrl
IntlChar::isJavaIDPart
Check if code point is permissible in a Java identifier
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isJavaIDPart ( <span
class="methodparam">mixed $codepoint
)
Determines if the specified character is permissible in a Java identifier.
In addition to IntlChar::isIDPart,
true
for characters with general category "Sc" (currency symbols).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
may occur in a Java identifier,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isJavaIDPart("A"));
var_dump(IntlChar::isJavaIDPart("$"));
var_dump(IntlChar::isJavaIDPart("\n"));
var_dump(IntlChar::isJavaIDPart("\u{2603}"));
?>
以上例程会输出:
bool(true)
bool(true)
bool(false)
bool(false)
参见
- IntlChar::isIDIgnorable
- IntlChar::isIDPart
- IntlChar::isJavaIDStart
- IntlChar::isalpha
- IntlChar::isdigit
IntlChar::isJavaIDStart
Check if code point is permissible as the first character in a Java identifier
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isJavaIDStart ( <span
class="methodparam">mixed $codepoint
)
Determines if the specified character is permissible as the start of a Java identifier.
In addition to IntlChar::isIDStart,
true
for characters with general categories "Sc" (currency
symbols) and "Pc" (connecting punctuation).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
may start a Java identifier,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isJavaIDStart("A"));
var_dump(IntlChar::isJavaIDStart("$"));
var_dump(IntlChar::isJavaIDStart("\n"));
var_dump(IntlChar::isJavaIDStart("\u{2603}"));
?>
以上例程会输出:
bool(true)
bool(true)
bool(false)
bool(false)
参见
- IntlChar::isIDStart
- IntlChar::isJavaIDPart
- IntlChar::isalpha
IntlChar::isJavaSpaceChar
Check if code point is a space character according to Java
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isJavaSpaceChar ( <span
class="methodparam">mixed $codepoint
)
Determine if the specified code point is a space character according to Java.
true
for characters with general categories "Z" (separators),
which does not include control codes (e.g., TAB or Line Feed).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a space character according to
Java, false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isJavaSpaceChar("A"));
var_dump(IntlChar::isJavaSpaceChar(" "));
var_dump(IntlChar::isJavaSpaceChar("\n"));
var_dump(IntlChar::isJavaSpaceChar("\t"));
var_dump(IntlChar::isJavaSpaceChar("\u{00A0}"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(false)
bool(false)
bool(true)
参见
- IntlChar::isspace
- IntlChar::isWhitespace
- IntlChar::isUWhiteSpace
IntlChar::islower
Check if code point is a lowercase letter
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::islower ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point has the general category "Ll" (lowercase letter).
Note:
This misses some characters that are also lowercase but have a different general category value. In order to include those, use <span class="function">IntlChar::isULowercase.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is an Ll lowercase letter, false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::islower("A"));
var_dump(IntlChar::islower("a"));
var_dump(IntlChar::islower("Φ"));
var_dump(IntlChar::islower("φ"));
var_dump(IntlChar::islower("1"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
参见
- IntlChar::isupper
- IntlChar::istitle
- IntlChar::tolower
- IntlChar::toupper
IntlChar::PROPERTY_LOWERCASE
IntlChar::isMirrored
Check if code point has the Bidi_Mirrored property
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isMirrored ( <span
class="methodparam">mixed $codepoint
)
Determines whether the code point has the Bidi_Mirrored property.
This property is set for characters that are commonly used in Right-To-Left contexts and need to be displayed with a "mirrored" glyph.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
has the Bidi_Mirrored property,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isMirrored("A"));
var_dump(IntlChar::isMirrored("<"));
var_dump(IntlChar::isMirrored("("));
?>
以上例程会输出:
bool(false)
bool(true)
bool(true)
参见
- IntlChar::charMirror
IntlChar::PROPERTY_BIDI_MIRRORED
IntlChar::isprint
Check if code point is a printable character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isprint ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a printable character.
true
for general categories other than "C" (controls).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a printable character, false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isprint("A"));
var_dump(IntlChar::isprint(" "));
var_dump(IntlChar::isprint("\n"));
var_dump(IntlChar::isprint("\u{200e}"));
?>
以上例程会输出:
bool(true)
bool(true)
bool(false)
bool(false)
参见
- IntlChar::iscntrl
IntlChar::PROPERTY_DEFAULT_IGNORABLE_CODE_POINT
IntlChar::ispunct
Check if code point is punctuation character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::ispunct ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a punctuation character.
true
for characters with general categories "P" (punctuation).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a punctuation character,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::ispunct("."));
var_dump(IntlChar::ispunct(","));
var_dump(IntlChar::ispunct("\n"));
var_dump(IntlChar::ispunct("$"));
以上例程会输出:
bool(true)
bool(true)
bool(false)
bool(false)
IntlChar::isspace
Check if code point is a space character
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isspace ( <span
class="methodparam">mixed $codepoint
)
Determines if the specified character is a space character or not.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a space character, false
if
not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isspace("A"));
var_dump(IntlChar::isspace(" "));
var_dump(IntlChar::isspace("\n"));
var_dump(IntlChar::isspace("\t"));
var_dump(IntlChar::isspace("\u{00A0}"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
参见
- IntlChar::isJavaSpaceChar
- IntlChar::isWhitespace
- IntlChar::isUWhiteSpace
IntlChar::istitle
Check if code point is a titlecase letter
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::istitle ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a titlecase letter.
true
for general category "Lt" (titlecase letter).
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a titlecase letter, false
if
not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::istitle("A"));
var_dump(IntlChar::istitle("a"));
var_dump(IntlChar::istitle("Φ"));
var_dump(IntlChar::istitle("φ"));
var_dump(IntlChar::istitle("1"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
参见
- IntlChar::isupper
- IntlChar::islower
- IntlChar::totitle
IntlChar::isUAlphabetic
Check if code point has the Alphabetic Unicode property
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isUAlphabetic ( <span
class="methodparam">mixed $codepoint
)
Check if a code point has the Alphabetic Unicode property.
This is the same as IntlChar::hasBinaryProperty($codepoint, IntlChar::PROPERTY_ALPHABETIC)
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
has the Alphabetic Unicode property,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isUAlphabetic("A"));
var_dump(IntlChar::isUAlphabetic("1"));
var_dump(IntlChar::isUAlphabetic("\u{2603}"));
?>
以上例程会输出:
bool(true)
bool(false)
bool(false)
参见
- IntlChar::isalpha
- IntlChar::hasBinaryProperty
IntlChar::PROPERTY_ALPHABETIC
IntlChar::isULowercase
Check if code point has the Lowercase Unicode property
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isULowercase ( <span
class="methodparam">mixed $codepoint
)
Check if a code point has the Lowercase Unicode property.
This is the same as IntlChar::hasBinaryProperty($codepoint, IntlChar::PROPERTY_LOWERCASE)
Note:
This is different than IntlChar::islower and will return
true
for more characters.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
has the Lowercase Unicode property,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isULowercase("A"));
var_dump(IntlChar::isULowercase("a"));
var_dump(IntlChar::isULowercase("Φ"));
var_dump(IntlChar::isULowercase("φ"));
var_dump(IntlChar::isULowercase("1"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
参见
- IntlChar::islower
- IntlChar::hasBinaryProperty
IntlChar::PROPERTY_LOWERCASE
IntlChar::isupper
Check if code point has the general category "Lu" (uppercase letter)
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isupper ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point has the general category "Lu" (uppercase letter).
Note:
This misses some characters that are also uppercase but have a different general category value. In order to include those, use <span class="function">IntlChar::isUUppercase.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is an Lu uppercase letter, false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isupper("A"));
var_dump(IntlChar::isupper("a"));
var_dump(IntlChar::isupper("Φ"));
var_dump(IntlChar::isupper("φ"));
var_dump(IntlChar::isupper("1"));
?>
以上例程会输出:
bool(true)
bool(false)
bool(true)
bool(false)
bool(false)
参见
- IntlChar::islower
- IntlChar::istitle
- IntlChar::tolower
- IntlChar::toupper
IntlChar::PROPERTY_UPPERCASE
IntlChar::isUUppercase
Check if code point has the Uppercase Unicode property
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isUUppercase ( <span
class="methodparam">mixed $codepoint
)
Check if a code point has the Uppercase Unicode property.
This is the same as IntlChar::hasBinaryProperty($codepoint, IntlChar::PROPERTY_UPPERCASE)
Note:
This is different than IntlChar::isupper and will return
true
for more characters.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
has the Uppercase Unicode property,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isUUppercase("A"));
var_dump(IntlChar::isUUppercase("a"));
var_dump(IntlChar::isUUppercase("Φ"));
var_dump(IntlChar::isUUppercase("φ"));
var_dump(IntlChar::isUUppercase("1"));
?>
以上例程会输出:
bool(true)
bool(false)
bool(true)
bool(false)
bool(false)
参见
- IntlChar::isupper
- IntlChar::hasBinaryProperty
IntlChar::PROPERTY_UPPERCASE
IntlChar::isUWhiteSpace
Check if code point has the White_Space Unicode property
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isUWhiteSpace ( <span
class="methodparam">mixed $codepoint
)
Check if a code point has the White_Space Unicode property.
This is the same as IntlChar::hasBinaryProperty($codepoint, IntlChar::PROPERTY_WHITE_SPACE)
Note:
This is different from both <span class="function">IntlChar::isspace and <span class="function">IntlChar::isWhitespace.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
has the White_Space Unicode property,
false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isUWhiteSpace("A"));
var_dump(IntlChar::isUWhiteSpace(" "));
var_dump(IntlChar::isUWhiteSpace("\n"));
var_dump(IntlChar::isUWhiteSpace("\t"));
var_dump(IntlChar::isUWhiteSpace("\u{00A0}"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
参见
- IntlChar::isspace
- IntlChar::isWhitespace
- IntlChar::isJavaSpaceChar
- IntlChar::hasBinaryProperty
IntlChar::PROPERTY_WHITE_SPACE
IntlChar::isWhitespace
Check if code point is a whitespace character according to ICU
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isWhitespace ( <span
class="methodparam">mixed $codepoint
)
Determines if the specified code point is a whitespace character according to ICU.
A character is considered to be a ICU whitespace character if and only if it satisfies one of the following criteria:
- It is a Unicode Separator character (categories "Z" = "Zs" or "Zl" or "Zp"), but is not also a non-breaking space (U+00A0 NBSP or U+2007 Figure Space or U+202F Narrow NBSP).
- It is U+0009 HORIZONTAL TABULATION.
- It is U+000A LINE FEED.
- It is U+000B VERTICAL TABULATION.
- It is U+000C FORM FEED.
- It is U+000D CARRIAGE RETURN.
- It is U+001C FILE SEPARATOR.
- It is U+001D GROUP SEPARATOR.
- It is U+001E RECORD SEPARATOR.
- It is U+001F UNIT SEPARATOR.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a whitespace character according to
ICU, false
if not.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::iswhitespace("A"));
var_dump(IntlChar::iswhitespace(" "));
var_dump(IntlChar::iswhitespace("\n"));
var_dump(IntlChar::iswhitespace("\t"));
var_dump(IntlChar::iswhitespace("\u{00A0}"));
?>
以上例程会输出:
bool(false)
bool(true)
bool(true)
bool(true)
bool(false)
参见
- IntlChar::isspace
- IntlChar::isJavaSpaceChar
- IntlChar::isUWhiteSpace
IntlChar::isxdigit
Check if code point is a hexadecimal digit
说明
public <span
class="modifier">static bool <span
class="methodname">IntlChar::isxdigit ( <span
class="methodparam">mixed $codepoint
)
Determines whether the specified code point is a hexadecimal digit.
true
for characters with general category "Nd" (decimal digit
numbers) as well as Latin letters a-f and A-F in both ASCII and
Fullwidth ASCII. (That is, for letters with code points 0041..0046,
0061..0066, FF21..FF26, FF41..FF46.)
This is equivalent to IntlChar::digit($codepoint, 16) >= 0.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns true
if codepoint
is a hexadecimal character,
false
if not.
注释
Note:
In order to narrow the definition of hexadecimal digits to only ASCII characters use:
<?php $isASCIIHexadecimal = IntlChar::ord($codepoint) <= 0x7F && IntlChar::isxdigit($codepoint); ?>
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::isxdigit("A"));
var_dump(IntlChar::isxdigit("1"));
var_dump(IntlChar::isxdigit("\u{2603}"));
?>
以上例程会输出:
bool(true)
bool(true)
bool(false)
参见
- IntlChar::isdigit
IntlChar::ord
Return Unicode code point value of character
说明
public <span
class="modifier">static int <span
class="methodname">IntlChar::ord ( <span
class="methodparam">mixed $character
)
Returns the Unicode code point value of the given character.
This function compliments IntlChar::chr.
参数
character
A Unicode character.
返回值
Returns the Unicode code point value as an integer.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::ord("A"));
var_dump(IntlChar::ord(" "));
var_dump(IntlChar::ord("\u{2603}"));
?>
以上例程会输出:
int(65)
int(32)
int(9731)
参见
- IntlChar::isalnum
- IntlChar::isdigit
- IntlChar::chr
- ord
IntlChar::tolower
Make Unicode character lowercase
说明
public <span
class="modifier">static mixed <span
class="methodname">IntlChar::tolower ( <span
class="methodparam">mixed $codepoint
)
The given character is mapped to its lowercase equivalent. If the character has no lowercase equivalent, the original character itself is returned.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns the Simple_Lowercase_Mapping of the code point, if any; otherwise the code point itself.
The return type will be int unless the code point was passed as a UTF-8 string, in which case a string will be returned.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::tolower("A"));
var_dump(IntlChar::tolower("a"));
var_dump(IntlChar::tolower("Φ"));
var_dump(IntlChar::tolower("φ"));
var_dump(IntlChar::tolower("1"));
var_dump(IntlChar::tolower(ord("A")));
var_dump(IntlChar::tolower(ord("a")));
?>
以上例程会输出:
string(1) "a"
string(1) "a"
string(2) "φ"
string(2) "φ"
string(1) "1"
int(97)
int(97)
参见
- IntlChar::totitle
- IntlChar::toupper
- mb_strtolower
IntlChar::totitle
Make Unicode character titlecase
说明
public <span
class="modifier">static mixed <span
class="methodname">IntlChar::totitle ( <span
class="methodparam">mixed $codepoint
)
The given character is mapped to its titlecase equivalent. If the character has no titlecase equivalent, the original character itself is returned.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns the Simple_Titlecase_Mapping of the code point, if any; otherwise the code point itself.
The return type will be int unless the code point was passed as a UTF-8 string, in which case a string will be returned.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::totitle("A"));
var_dump(IntlChar::totitle("a"));
var_dump(IntlChar::totitle("Φ"));
var_dump(IntlChar::totitle("φ"));
var_dump(IntlChar::totitle("1"));
var_dump(IntlChar::totitle(ord("A")));
var_dump(IntlChar::totitle(ord("a")));
?>
以上例程会输出:
string(1) "A"
string(1) "A"
string(2) "Φ"
string(2) "Φ"
string(1) "1"
int(65)
int(65)
参见
- IntlChar::tolower
- IntlChar::toupper
- mb_convert_case
IntlChar::toupper
Make Unicode character uppercase
说明
public <span
class="modifier">static mixed <span
class="methodname">IntlChar::toupper ( <span
class="methodparam">mixed $codepoint
)
The given character is mapped to its uppercase equivalent. If the character has no uppercase equivalent, the character itself is returned.
参数
codepoint
The int codepoint value (e.g. 0x2603 for
U+2603 SNOWMAN), or the character encoded as a UTF-8 <span
class="type">string (e.g. "\u{2603}")
返回值
Returns the Simple_Uppercase_Mapping of the code point, if any; otherwise the code point itself.
The return type will be int unless the code point was passed as a UTF-8 string, in which case a string will be returned.
范例
示例 #1 Testing different code points
<?php
var_dump(IntlChar::toupper("A"));
var_dump(IntlChar::toupper("a"));
var_dump(IntlChar::toupper("Φ"));
var_dump(IntlChar::toupper("φ"));
var_dump(IntlChar::toupper("1"));
var_dump(IntlChar::toupper(ord("A")));
var_dump(IntlChar::toupper(ord("a")));
?>
以上例程会输出:
string(1) "A"
string(1) "A"
string(2) "Φ"
string(2) "Φ"
string(1) "1"
int(65)
int(65)
参见
- IntlChar::tolower
- IntlChar::totitle
- mb_strtoupper
简介
This class is used for generating exceptions when errors occur inside intl functions. Such exceptions are only generated when intl.use_exceptions is enabled.
类摘要
IntlException
class IntlException <span class="ooclass"> extends Exception {
/* 继承的属性 */
protected string
$message
;
protected int
$code
;
protected string
$file
;
protected int
$line
;
/* 继承的方法 */
final public string <span class="methodname">Exception::getMessage ( <span class="methodparam">void )
final public Throwable <span class="methodname">Exception::getPrevious ( <span class="methodparam">void )
final public mixed <span class="methodname">Exception::getCode ( <span class="methodparam">void )
final public string <span class="methodname">Exception::getFile ( <span class="methodparam">void )
final public int <span class="methodname">Exception::getLine ( <span class="methodparam">void )
final public array <span class="methodname">Exception::getTrace ( <span class="methodparam">void )
final public string <span class="methodname">Exception::getTraceAsString ( <span class="methodparam">void )
public string Exception::__toString ( <span class="methodparam">void )
final <span class="modifier">private void <span class="methodname">Exception::__clone ( <span class="methodparam">void )
}
简介
This class represents iterator objects throughout the intl extension whenever the iterator cannot be identified with any other object provided by the extension. The distinct iterator object used internally by the foreach construct can only be obtained (in the relevant part here) from objects, so objects of this class serve the purpose of providing the hook through which this internal object can be obtained. As a convenience, this class also implements the Iterator interface, allowing the collection of values to be navigated using the methods defined in that interface. Both these methods and the internal iterator objects provided to foreach are backed by the same state (e.g. the position of the iterator and its current value).
Subclasses may provide richer functionality.
类摘要
IntlIterator
class IntlIterator <span class="oointerface">implements <span class="interfacename">Iterator {
/* 方法 */
public mixed current ( <span class="methodparam">void )
public string key ( <span class="methodparam">void )
public void next ( <span class="methodparam">void )
public void rewind ( <span class="methodparam">void )
public bool valid ( <span class="methodparam">void )
}
IntlIterator::current
Get the current element
说明
public mixed IntlIterator::current ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlIterator::key
Get the current key
说明
public string IntlIterator::key ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlIterator::next
Move forward to the next element
说明
public void IntlIterator::next ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlIterator::rewind
Rewind the iterator to the first element
说明
public void IntlIterator::rewind ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
IntlIterator::valid
Check if current position is valid
说明
public bool IntlIterator::valid ( <span class="methodparam">void )
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。