cakephp2-php8/cake/libs/multibyte.php
Mark Story 4f67f84ff8 Merge branch '1.2' into 1.3-merger
Conflicts:
	app/config/acl.ini.php
	app/config/bootstrap.php
	app/config/core.php
	app/config/database.php.default
	app/config/inflections.php
	app/config/routes.php
	app/config/schema/db_acl.php
	app/config/schema/i18n.php
	app/config/schema/sessions.php
	app/config/sql/db_acl.sql
	app/config/sql/i18n.sql
	app/index.php
	app/webroot/css.php
	app/webroot/css/cake.generic.css
	app/webroot/index.php
	app/webroot/js/vendors.php
	app/webroot/test.php
	cake/LICENSE.txt
	cake/basics.php
	cake/bootstrap.php
	cake/config/config.php
	cake/config/paths.php
	cake/config/unicode/casefolding/0080_00ff.php
	cake/config/unicode/casefolding/0100_017f.php
	cake/config/unicode/casefolding/0180_024F.php
	cake/config/unicode/casefolding/0250_02af.php
	cake/config/unicode/casefolding/0370_03ff.php
	cake/config/unicode/casefolding/0400_04ff.php
	cake/config/unicode/casefolding/0500_052f.php
	cake/config/unicode/casefolding/0530_058f.php
	cake/config/unicode/casefolding/1e00_1eff.php
	cake/config/unicode/casefolding/1f00_1fff.php
	cake/config/unicode/casefolding/2100_214f.php
	cake/config/unicode/casefolding/2150_218f.php
	cake/config/unicode/casefolding/2460_24ff.php
	cake/config/unicode/casefolding/2c00_2c5f.php
	cake/config/unicode/casefolding/2c60_2c7f.php
	cake/config/unicode/casefolding/2c80_2cff.php
	cake/config/unicode/casefolding/ff00_ffef.php
	cake/console/cake
	cake/console/cake.bat
	cake/console/cake.php
	cake/console/error.php
	cake/console/libs/acl.php
	cake/console/libs/api.php
	cake/console/libs/bake.php
	cake/console/libs/console.php
	cake/console/libs/i18n.php
	cake/console/libs/schema.php
	cake/console/libs/shell.php
	cake/console/libs/tasks/controller.php
	cake/console/libs/tasks/db_config.php
	cake/console/libs/tasks/extract.php
	cake/console/libs/tasks/model.php
	cake/console/libs/tasks/plugin.php
	cake/console/libs/tasks/project.php
	cake/console/libs/tasks/test.php
	cake/console/libs/tasks/view.php
	cake/console/libs/templates/skel/config/bootstrap.php
	cake/console/libs/templates/skel/config/inflections.php
	cake/console/libs/templates/skel/config/sql/sessions.sql
	cake/console/libs/templates/skel/index.php
	cake/console/libs/templates/skel/views/elements/email/html/default.ctp
	cake/console/libs/templates/skel/views/elements/email/text/default.ctp
	cake/console/libs/templates/skel/views/layouts/ajax.ctp
	cake/console/libs/templates/skel/views/layouts/default.ctp
	cake/console/libs/templates/skel/views/layouts/email/html/default.ctp
	cake/console/libs/templates/skel/views/layouts/email/text/default.ctp
	cake/console/libs/templates/skel/webroot/js/vendors.php
	cake/console/libs/templates/skel/webroot/test.php
	cake/console/libs/templates/views/form.ctp
	cake/console/libs/templates/views/index.ctp
	cake/console/libs/testsuite.php
	cake/console/templates/default/views/view.ctp
	cake/console/templates/skel/app_controller.php
	cake/console/templates/skel/app_helper.php
	cake/console/templates/skel/app_model.php
	cake/console/templates/skel/config/acl.ini.php
	cake/console/templates/skel/config/core.php
	cake/console/templates/skel/config/database.php.default
	cake/console/templates/skel/config/routes.php
	cake/console/templates/skel/config/schema/db_acl.php
	cake/console/templates/skel/config/schema/db_acl.sql
	cake/console/templates/skel/config/schema/i18n.php
	cake/console/templates/skel/config/schema/i18n.sql
	cake/console/templates/skel/config/schema/sessions.php
	cake/console/templates/skel/config/schema/sessions.sql
	cake/console/templates/skel/controllers/pages_controller.php
	cake/console/templates/skel/views/layouts/flash.ctp
	cake/console/templates/skel/webroot/css.php
	cake/console/templates/skel/webroot/css/cake.generic.css
	cake/console/templates/skel/webroot/index.php
	cake/dispatcher.php
	cake/libs/cache.php
	cake/libs/cache/apc.php
	cake/libs/cache/file.php
	cake/libs/cache/memcache.php
	cake/libs/cache/xcache.php
	cake/libs/cake_log.php
	cake/libs/cake_session.php
	cake/libs/cake_socket.php
	cake/libs/class_registry.php
	cake/libs/configure.php
	cake/libs/controller/app_controller.php
	cake/libs/controller/component.php
	cake/libs/controller/components/acl.php
	cake/libs/controller/components/auth.php
	cake/libs/controller/components/cookie.php
	cake/libs/controller/components/email.php
	cake/libs/controller/components/request_handler.php
	cake/libs/controller/components/security.php
	cake/libs/controller/components/session.php
	cake/libs/controller/controller.php
	cake/libs/controller/pages_controller.php
	cake/libs/controller/scaffold.php
	cake/libs/debugger.php
	cake/libs/error.php
	cake/libs/file.php
	cake/libs/flay.php
	cake/libs/folder.php
	cake/libs/http_socket.php
	cake/libs/i18n.php
	cake/libs/inflector.php
	cake/libs/l10n.php
	cake/libs/magic_db.php
	cake/libs/model/app_model.php
	cake/libs/model/behaviors/acl.php
	cake/libs/model/behaviors/containable.php
	cake/libs/model/behaviors/translate.php
	cake/libs/model/behaviors/tree.php
	cake/libs/model/cake_schema.php
	cake/libs/model/connection_manager.php
	cake/libs/model/datasources/datasource.php
	cake/libs/model/datasources/dbo/dbo_adodb.php
	cake/libs/model/datasources/dbo/dbo_db2.php
	cake/libs/model/datasources/dbo/dbo_firebird.php
	cake/libs/model/datasources/dbo/dbo_mssql.php
	cake/libs/model/datasources/dbo/dbo_mysql.php
	cake/libs/model/datasources/dbo/dbo_mysqli.php
	cake/libs/model/datasources/dbo/dbo_odbc.php
	cake/libs/model/datasources/dbo/dbo_oracle.php
	cake/libs/model/datasources/dbo/dbo_postgres.php
	cake/libs/model/datasources/dbo/dbo_sqlite.php
	cake/libs/model/datasources/dbo/dbo_sybase.php
	cake/libs/model/datasources/dbo_source.php
	cake/libs/model/db_acl.php
	cake/libs/model/model.php
	cake/libs/model/model_behavior.php
	cake/libs/multibyte.php
	cake/libs/object.php
	cake/libs/overloadable.php
	cake/libs/overloadable_php4.php
	cake/libs/overloadable_php5.php
	cake/libs/router.php
	cake/libs/sanitize.php
	cake/libs/security.php
	cake/libs/set.php
	cake/libs/string.php
	cake/libs/validation.php
	cake/libs/view/elements/dump.ctp
	cake/libs/view/elements/email/html/default.ctp
	cake/libs/view/elements/email/text/default.ctp
	cake/libs/view/errors/error404.ctp
	cake/libs/view/errors/missing_action.ctp
	cake/libs/view/errors/missing_component_class.ctp
	cake/libs/view/errors/missing_component_file.ctp
	cake/libs/view/errors/missing_connection.ctp
	cake/libs/view/errors/missing_controller.ctp
	cake/libs/view/errors/missing_helper_class.ctp
	cake/libs/view/errors/missing_helper_file.ctp
	cake/libs/view/errors/missing_layout.ctp
	cake/libs/view/errors/missing_model.ctp
	cake/libs/view/errors/missing_scaffolddb.ctp
	cake/libs/view/errors/missing_table.ctp
	cake/libs/view/errors/missing_view.ctp
	cake/libs/view/errors/private_action.ctp
	cake/libs/view/errors/scaffold_error.ctp
	cake/libs/view/helper.php
	cake/libs/view/helpers/ajax.php
	cake/libs/view/helpers/app_helper.php
	cake/libs/view/helpers/cache.php
	cake/libs/view/helpers/form.php
	cake/libs/view/helpers/html.php
	cake/libs/view/helpers/javascript.php
	cake/libs/view/helpers/js.php
	cake/libs/view/helpers/number.php
	cake/libs/view/helpers/paginator.php
	cake/libs/view/helpers/rss.php
	cake/libs/view/helpers/session.php
	cake/libs/view/helpers/text.php
	cake/libs/view/helpers/time.php
	cake/libs/view/helpers/xml.php
	cake/libs/view/layouts/ajax.ctp
	cake/libs/view/layouts/default.ctp
	cake/libs/view/layouts/email/html/default.ctp
	cake/libs/view/layouts/email/text/default.ctp
	cake/libs/view/layouts/flash.ctp
	cake/libs/view/media.php
	cake/libs/view/pages/home.ctp
	cake/libs/view/scaffolds/edit.ctp
	cake/libs/view/scaffolds/index.ctp
	cake/libs/view/scaffolds/view.ctp
	cake/libs/view/theme.php
	cake/libs/view/view.php
	cake/libs/xml.php
	cake/tests/cases/basics.test.php
	cake/tests/cases/console/cake.test.php
	cake/tests/cases/console/libs/acl.test.php
	cake/tests/cases/console/libs/api.test.php
	cake/tests/cases/console/libs/schema.test.php
	cake/tests/cases/console/libs/shell.test.php
	cake/tests/cases/console/libs/tasks/extract.test.php
	cake/tests/cases/console/libs/tasks/model.test.php
	cake/tests/cases/console/libs/tasks/test.test.php
	cake/tests/cases/dispatcher.test.php
	cake/tests/cases/libs/cache.test.php
	cake/tests/cases/libs/cache/apc.test.php
	cake/tests/cases/libs/cache/file.test.php
	cake/tests/cases/libs/cache/memcache.test.php
	cake/tests/cases/libs/cache/xcache.test.php
	cake/tests/cases/libs/cake_log.test.php
	cake/tests/cases/libs/cake_session.test.php
	cake/tests/cases/libs/cake_socket.test.php
	cake/tests/cases/libs/cake_test_case.test.php
	cake/tests/cases/libs/cake_test_fixture.test.php
	cake/tests/cases/libs/class_registry.test.php
	cake/tests/cases/libs/code_coverage_manager.test.php
	cake/tests/cases/libs/configure.test.php
	cake/tests/cases/libs/controller/component.test.php
	cake/tests/cases/libs/controller/components/acl.test.php
	cake/tests/cases/libs/controller/components/auth.test.php
	cake/tests/cases/libs/controller/components/cookie.test.php
	cake/tests/cases/libs/controller/components/email.test.php
	cake/tests/cases/libs/controller/components/request_handler.test.php
	cake/tests/cases/libs/controller/components/security.test.php
	cake/tests/cases/libs/controller/components/session.test.php
	cake/tests/cases/libs/controller/controller.test.php
	cake/tests/cases/libs/controller/controller_merge_vars.test.php
	cake/tests/cases/libs/controller/pages_controller.test.php
	cake/tests/cases/libs/controller/scaffold.test.php
	cake/tests/cases/libs/debugger.test.php
	cake/tests/cases/libs/error.test.php
	cake/tests/cases/libs/file.test.php
	cake/tests/cases/libs/flay.test.php
	cake/tests/cases/libs/folder.test.php
	cake/tests/cases/libs/http_socket.test.php
	cake/tests/cases/libs/i18n.test.php
	cake/tests/cases/libs/inflector.test.php
	cake/tests/cases/libs/l10n.test.php
	cake/tests/cases/libs/magic_db.test.php
	cake/tests/cases/libs/model/behaviors/acl.test.php
	cake/tests/cases/libs/model/behaviors/containable.test.php
	cake/tests/cases/libs/model/behaviors/translate.test.php
	cake/tests/cases/libs/model/behaviors/tree.test.php
	cake/tests/cases/libs/model/cake_schema.test.php
	cake/tests/cases/libs/model/connection_manager.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
	cake/tests/cases/libs/model/datasources/dbo_source.test.php
	cake/tests/cases/libs/model/db_acl.test.php
	cake/tests/cases/libs/model/model.test.php
	cake/tests/cases/libs/model/model_behavior.test.php
	cake/tests/cases/libs/model/model_delete.test.php
	cake/tests/cases/libs/model/model_integration.test.php
	cake/tests/cases/libs/model/model_read.test.php
	cake/tests/cases/libs/model/model_validation.test.php
	cake/tests/cases/libs/model/model_write.test.php
	cake/tests/cases/libs/model/models.php
	cake/tests/cases/libs/multibyte.test.php
	cake/tests/cases/libs/object.test.php
	cake/tests/cases/libs/overloadable.test.php
	cake/tests/cases/libs/router.test.php
	cake/tests/cases/libs/sanitize.test.php
	cake/tests/cases/libs/security.test.php
	cake/tests/cases/libs/set.test.php
	cake/tests/cases/libs/string.test.php
	cake/tests/cases/libs/test_manager.test.php
	cake/tests/cases/libs/validation.test.php
	cake/tests/cases/libs/view/helper.test.php
	cake/tests/cases/libs/view/helpers/ajax.test.php
	cake/tests/cases/libs/view/helpers/cache.test.php
	cake/tests/cases/libs/view/helpers/form.test.php
	cake/tests/cases/libs/view/helpers/html.test.php
	cake/tests/cases/libs/view/helpers/javascript.test.php
	cake/tests/cases/libs/view/helpers/js.test.php
	cake/tests/cases/libs/view/helpers/number.test.php
	cake/tests/cases/libs/view/helpers/paginator.test.php
	cake/tests/cases/libs/view/helpers/rss.test.php
	cake/tests/cases/libs/view/helpers/session.test.php
	cake/tests/cases/libs/view/helpers/text.test.php
	cake/tests/cases/libs/view/helpers/time.test.php
	cake/tests/cases/libs/view/helpers/xml.test.php
	cake/tests/cases/libs/view/theme.test.php
	cake/tests/cases/libs/view/view.test.php
	cake/tests/cases/libs/xml.test.php
	cake/tests/fixtures/account_fixture.php
	cake/tests/fixtures/aco_action_fixture.php
	cake/tests/fixtures/aco_fixture.php
	cake/tests/fixtures/aco_two_fixture.php
	cake/tests/fixtures/advertisement_fixture.php
	cake/tests/fixtures/another_article_fixture.php
	cake/tests/fixtures/apple_fixture.php
	cake/tests/fixtures/aro_fixture.php
	cake/tests/fixtures/aro_two_fixture.php
	cake/tests/fixtures/aros_aco_fixture.php
	cake/tests/fixtures/aros_aco_two_fixture.php
	cake/tests/fixtures/article_featured_fixture.php
	cake/tests/fixtures/article_featureds_tags_fixture.php
	cake/tests/fixtures/article_fixture.php
	cake/tests/fixtures/articles_tag_fixture.php
	cake/tests/fixtures/attachment_fixture.php
	cake/tests/fixtures/auth_user_custom_field_fixture.php
	cake/tests/fixtures/auth_user_fixture.php
	cake/tests/fixtures/author_fixture.php
	cake/tests/fixtures/basket_fixture.php
	cake/tests/fixtures/bid_fixture.php
	cake/tests/fixtures/binary_test_fixture.php
	cake/tests/fixtures/book_fixture.php
	cake/tests/fixtures/cache_test_model_fixture.php
	cake/tests/fixtures/callback_fixture.php
	cake/tests/fixtures/category_fixture.php
	cake/tests/fixtures/category_thread_fixture.php
	cake/tests/fixtures/cd_fixture.php
	cake/tests/fixtures/comment_fixture.php
	cake/tests/fixtures/content_account_fixture.php
	cake/tests/fixtures/content_fixture.php
	cake/tests/fixtures/counter_cache_post_fixture.php
	cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php
	cake/tests/fixtures/counter_cache_user_fixture.php
	cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php
	cake/tests/fixtures/data_test_fixture.php
	cake/tests/fixtures/datatype_fixture.php
	cake/tests/fixtures/dependency_fixture.php
	cake/tests/fixtures/device_fixture.php
	cake/tests/fixtures/device_type_category_fixture.php
	cake/tests/fixtures/device_type_fixture.php
	cake/tests/fixtures/document_directory_fixture.php
	cake/tests/fixtures/document_fixture.php
	cake/tests/fixtures/exterior_type_category_fixture.php
	cake/tests/fixtures/feature_set_fixture.php
	cake/tests/fixtures/featured_fixture.php
	cake/tests/fixtures/film_file_fixture.php
	cake/tests/fixtures/flag_tree_fixture.php
	cake/tests/fixtures/fruit_fixture.php
	cake/tests/fixtures/fruits_uuid_tag_fixture.php
	cake/tests/fixtures/home_fixture.php
	cake/tests/fixtures/image_fixture.php
	cake/tests/fixtures/item_fixture.php
	cake/tests/fixtures/items_portfolio_fixture.php
	cake/tests/fixtures/join_a_b_fixture.php
	cake/tests/fixtures/join_a_c_fixture.php
	cake/tests/fixtures/join_a_fixture.php
	cake/tests/fixtures/join_b_fixture.php
	cake/tests/fixtures/join_c_fixture.php
	cake/tests/fixtures/join_thing_fixture.php
	cake/tests/fixtures/message_fixture.php
	cake/tests/fixtures/my_categories_my_products_fixture.php
	cake/tests/fixtures/my_categories_my_users_fixture.php
	cake/tests/fixtures/my_category_fixture.php
	cake/tests/fixtures/my_product_fixture.php
	cake/tests/fixtures/my_user_fixture.php
	cake/tests/fixtures/node_fixture.php
	cake/tests/fixtures/number_tree_fixture.php
	cake/tests/fixtures/number_tree_two_fixture.php
	cake/tests/fixtures/numeric_article_fixture.php
	cake/tests/fixtures/overall_favorite_fixture.php
	cake/tests/fixtures/person_fixture.php
	cake/tests/fixtures/portfolio_fixture.php
	cake/tests/fixtures/post_fixture.php
	cake/tests/fixtures/posts_tag_fixture.php
	cake/tests/fixtures/primary_model_fixture.php
	cake/tests/fixtures/product_fixture.php
	cake/tests/fixtures/project_fixture.php
	cake/tests/fixtures/sample_fixture.php
	cake/tests/fixtures/secondary_model_fixture.php
	cake/tests/fixtures/session_fixture.php
	cake/tests/fixtures/something_else_fixture.php
	cake/tests/fixtures/something_fixture.php
	cake/tests/fixtures/stories_tag_fixture.php
	cake/tests/fixtures/story_fixture.php
	cake/tests/fixtures/syfile_fixture.php
	cake/tests/fixtures/tag_fixture.php
	cake/tests/fixtures/test_plugin_article_fixture.php
	cake/tests/fixtures/test_plugin_comment_fixture.php
	cake/tests/fixtures/the_paper_monkies_fixture.php
	cake/tests/fixtures/thread_fixture.php
	cake/tests/fixtures/translate_article_fixture.php
	cake/tests/fixtures/translate_fixture.php
	cake/tests/fixtures/translate_table_fixture.php
	cake/tests/fixtures/translated_article_fixture.php
	cake/tests/fixtures/translated_item_fixture.php
	cake/tests/fixtures/unconventional_tree_fixture.php
	cake/tests/fixtures/underscore_field_fixture.php
	cake/tests/fixtures/user_fixture.php
	cake/tests/fixtures/uuid_fixture.php
	cake/tests/fixtures/uuid_tag_fixture.php
	cake/tests/fixtures/uuid_tree_fixture.php
	cake/tests/fixtures/uuiditem_fixture.php
	cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php
	cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php
	cake/tests/fixtures/uuidportfolio_fixture.php
	cake/tests/groups/acl.group.php
	cake/tests/groups/cache.group.php
	cake/tests/groups/components.group.php
	cake/tests/groups/configure.group.php
	cake/tests/groups/console.group.php
	cake/tests/groups/controller.group.php
	cake/tests/groups/database.group.php
	cake/tests/groups/helpers.group.php
	cake/tests/groups/lib.group.php
	cake/tests/groups/model.group.php
	cake/tests/groups/no_cross_contamination.group.php
	cake/tests/groups/routing_system.group.php
	cake/tests/groups/socket.group.php
	cake/tests/groups/test_suite.group.php
	cake/tests/groups/view.group.php
	cake/tests/groups/xml.group.php
	cake/tests/lib/cake_reporter.php
	cake/tests/lib/cake_test_case.php
	cake/tests/lib/cake_test_fixture.php
	cake/tests/lib/cake_test_model.php
	cake/tests/lib/cake_web_test_case.php
	cake/tests/lib/cli_reporter.php
	cake/tests/lib/code_coverage_manager.php
	cake/tests/lib/templates/footer.php
	cake/tests/lib/templates/header.php
	cake/tests/lib/templates/menu.php
	cake/tests/lib/templates/simpletest.php
	cake/tests/lib/test_manager.php
	cake/tests/lib/xdebug.php
	cake/tests/test_app/config/acl.ini.php
	cake/tests/test_app/controllers/tests_apps_controller.php
	cake/tests/test_app/controllers/tests_apps_posts_controller.php
	cake/tests/test_app/models/behaviors/persister_one_behavior.php
	cake/tests/test_app/models/behaviors/persister_two_behavior.php
	cake/tests/test_app/models/comment.php
	cake/tests/test_app/models/persister_one.php
	cake/tests/test_app/models/persister_two.php
	cake/tests/test_app/models/post.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php
	cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php
	cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php
	cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php
	cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php
	cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php
	cake/tests/test_app/plugins/test_plugin/vendors/shells/example.php
	cake/tests/test_app/plugins/test_plugin/vendors/welcome.php
	cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php
	cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php
	cake/tests/test_app/plugins/test_plugin_two/vendors/shells/example.php
	cake/tests/test_app/plugins/test_plugin_two/vendors/shells/welcome.php
	cake/tests/test_app/vendors/Test/MyTest.php
	cake/tests/test_app/vendors/Test/hello.php
	cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php
	cake/tests/test_app/vendors/shells/sample.php
	cake/tests/test_app/vendors/somename/some.name.php
	cake/tests/test_app/vendors/welcome.php
	cake/tests/test_app/views/elements/email/html/default.ctp
	cake/tests/test_app/views/elements/email/text/default.ctp
	cake/tests/test_app/views/elements/email/text/wide.ctp
	cake/tests/test_app/views/layouts/ajax.ctp
	cake/tests/test_app/views/layouts/ajax2.ctp
	cake/tests/test_app/views/layouts/cache_layout.ctp
	cake/tests/test_app/views/layouts/default.ctp
	cake/tests/test_app/views/layouts/email/html/default.ctp
	cake/tests/test_app/views/layouts/email/html/thin.ctp
	cake/tests/test_app/views/layouts/email/text/default.ctp
	cake/tests/test_app/views/layouts/flash.ctp
	cake/tests/test_app/views/layouts/multi_cache.ctp
	cake/tests/test_app/views/posts/sequencial_nocache.ctp
	cake/tests/test_app/views/posts/test_nocache_tags.ctp
	index.php
2010-01-26 17:54:34 -05:00

1173 lines
No EOL
36 KiB
PHP

<?php
/**
* Multibyte handling methods.
*
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs
* @since CakePHP(tm) v 1.2.0.6833
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
if (function_exists('mb_internal_encoding')) {
$encoding = Configure::read('App.encoding');
if (!empty($encoding)) {
mb_internal_encoding($encoding);
}
}
/**
* Find position of first occurrence of a case-insensitive string.
*
* @param string $haystack The string from which to get the position of the first occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false
* if $needle is not found.
*/
if (!function_exists('mb_stripos')) {
function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) {
return Multibyte::stripos($haystack, $needle, $offset);
}
}
/**
* Finds first occurrence of a string within another, case insensitive.
*
* @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
* Default value is false.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string|boolean The portion of $haystack, or false if $needle is not found.
*/
if (!function_exists('mb_stristr')) {
function mb_stristr($haystack, $needle, $part = false, $encoding = null) {
return Multibyte::stristr($haystack, $needle, $part);
}
}
/**
* Get string length.
*
* @param string $string The string being checked for length.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer The number of characters in string $string having character encoding encoding.
* A multi-byte character is counted as 1.
*/
if (!function_exists('mb_strlen')) {
function mb_strlen($string, $encoding = null) {
return Multibyte::strlen($string);
}
}
/**
* Find position of first occurrence of a string.
*
* @param string $haystack The string being checked.
* @param string $needle The position counted from the beginning of haystack.
* @param integer $offset The search offset. If it is not specified, 0 is used.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string.
* If $needle is not found, it returns false.
*/
if (!function_exists('mb_strpos')) {
function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) {
return Multibyte::strpos($haystack, $needle, $offset);
}
}
/**
* Finds the last occurrence of a character in a string within another.
*
* @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
* If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
* Default value is false.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string|boolean The portion of $haystack. or false if $needle is not found.
*/
if (!function_exists('mb_strrchr')) {
function mb_strrchr($haystack, $needle, $part = false, $encoding = null) {
return Multibyte::strrchr($haystack, $needle, $part);
}
}
/**
* Finds the last occurrence of a character in a string within another, case insensitive.
*
* @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
* If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
* Default value is false.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string|boolean The portion of $haystack. or false if $needle is not found.
*/
if (!function_exists('mb_strrichr')) {
function mb_strrichr($haystack, $needle, $part = false, $encoding = null) {
return Multibyte::strrichr($haystack, $needle, $part);
}
}
/**
* Finds position of last occurrence of a string within another, case insensitive
*
* @param string $haystack The string from which to get the position of the last occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string,
* or false if $needle is not found.
*/
if (!function_exists('mb_strripos')) {
function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) {
return Multibyte::strripos($haystack, $needle, $offset);
}
}
/**
* Find position of last occurrence of a string in a string.
*
* @param string $haystack The string being checked, for the last occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param integer $offset May be specified to begin searching an arbitrary number of characters into the string.
* Negative values will stop searching at an arbitrary point prior to the end of the string.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string.
* If $needle is not found, it returns false.
*/
if (!function_exists('mb_strrpos')) {
function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) {
return Multibyte::strrpos($haystack, $needle, $offset);
}
}
/**
* Finds first occurrence of a string within another
*
* @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack
* @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
* Default value is FALSE.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string|boolean The portion of $haystack, or true if $needle is not found.
*/
if (!function_exists('mb_strstr')) {
function mb_strstr($haystack, $needle, $part = false, $encoding = null) {
return Multibyte::strstr($haystack, $needle, $part);
}
}
/**
* Make a string lowercase
*
* @param string $string The string being lowercased.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string with all alphabetic characters converted to lowercase.
*/
if (!function_exists('mb_strtolower')) {
function mb_strtolower($string, $encoding = null) {
return Multibyte::strtolower($string);
}
}
/**
* Make a string uppercase
*
* @param string $string The string being uppercased.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string with all alphabetic characters converted to uppercase.
*/
if (!function_exists('mb_strtoupper')) {
function mb_strtoupper($string, $encoding = null) {
return Multibyte::strtoupper($string);
}
}
/**
* Count the number of substring occurrences
*
* @param string $haystack The string being checked.
* @param string $needle The string being found.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer The number of times the $needle substring occurs in the $haystack string.
*/
if (!function_exists('mb_substr_count')) {
function mb_substr_count($haystack, $needle, $encoding = null) {
return Multibyte::substrCount($haystack, $needle);
}
}
/**
* Get part of string
*
* @param string $string The string being checked.
* @param integer $start The first position used in $string.
* @param integer $length The maximum length of the returned string.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string The portion of $string specified by the $string and $length parameters.
*/
if (!function_exists('mb_substr')) {
function mb_substr($string, $start, $length = null, $encoding = null) {
return Multibyte::substr($string, $start, $length);
}
}
/**
* Encode string for MIME header
*
* @param string $str The string being encoded
* @param string $charset specifies the name of the character set in which str is represented in.
* The default value is determined by the current NLS setting (mbstring.language).
* @param string $transfer_encoding specifies the scheme of MIME encoding.
* It should be either "B" (Base64) or "Q" (Quoted-Printable). Falls back to "B" if not given.
* @param string $linefeed specifies the EOL (end-of-line) marker with which
* mb_encode_mimeheader() performs line-folding
* (a » RFC term, the act of breaking a line longer than a certain length into multiple lines.
* The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given.
* @param integer $indent [definition unknown and appears to have no affect]
* @return string A converted version of the string represented in ASCII.
*/
if (!function_exists('mb_encode_mimeheader')) {
function mb_encode_mimeheader($str, $charset = 'UTF-8', $transfer_encoding = 'B', $linefeed = "\r\n", $indent = 1) {
return Multibyte::mimeEncode($str, $charset, $linefeed);
}
}
/**
* Multibyte handling methods.
*
*
* @package cake
* @subpackage cake.cake.libs
*/
class Multibyte extends Object {
/**
* Holds the case folding values
*
* @var array
* @access private
*/
var $__caseFold = array();
/**
* Holds an array of Unicode code point ranges
*
* @var array
* @access private
*/
var $__codeRange = array();
/**
* Holds the current code point range
*
* @var string
* @access private
*/
var $__table = null;
/**
* Gets a reference to the Multibyte object instance
*
* @return object Multibyte instance
* @access public
* @static
*/
function &getInstance() {
static $instance = array();
if (!$instance) {
$instance[0] =& new Multibyte();
}
return $instance[0];
}
/**
* Converts a multibyte character string
* to the decimal value of the character
*
* @param multibyte string $string
* @return array
* @access public
* @static
*/
function utf8($string) {
$map = array();
$values = array();
$find = 1;
$length = strlen($string);
for ($i = 0; $i < $length; $i++) {
$value = ord($string[$i]);
if ($value < 128) {
$map[] = $value;
} else {
if (empty($values)) {
$find = ($value < 224) ? 2 : 3;
}
$values[] = $value;
if (count($values) === $find) {
if ($find == 3) {
$map[] = (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64);
} else {
$map[] = (($values[0] % 32) * 64) + ($values[1] % 64);
}
$values = array();
$find = 1;
}
}
}
return $map;
}
/**
* Converts the decimal value of a multibyte character string
* to a string
*
* @param array $array
* @return string
* @access public
* @static
*/
function ascii($array) {
$ascii = '';
foreach ($array as $utf8) {
if ($utf8 < 128) {
$ascii .= chr($utf8);
} elseif ($utf8 < 2048) {
$ascii .= chr(192 + (($utf8 - ($utf8 % 64)) / 64));
$ascii .= chr(128 + ($utf8 % 64));
} else {
$ascii .= chr(224 + (($utf8 - ($utf8 % 4096)) / 4096));
$ascii .= chr(128 + ((($utf8 % 4096) - ($utf8 % 64)) / 64));
$ascii .= chr(128 + ($utf8 % 64));
}
}
return $ascii;
}
/**
* Find position of first occurrence of a case-insensitive string.
*
* @param multi-byte string $haystack The string from which to get the position of the first occurrence of $needle.
* @param multi-byte string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching.
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string,
* or false if $needle is not found.
* @access public
* @static
*/
function stripos($haystack, $needle, $offset = 0) {
if (!PHP5 || Multibyte::checkMultibyte($haystack)) {
$haystack = Multibyte::strtoupper($haystack);
$needle = Multibyte::strtoupper($needle);
return Multibyte::strpos($haystack, $needle, $offset);
}
return stripos($haystack, $needle, $offset);
}
/**
* Finds first occurrence of a string within another, case insensitive.
*
* @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
* Default value is false.
* @return int|boolean The portion of $haystack, or false if $needle is not found.
* @access public
* @static
*/
function stristr($haystack, $needle, $part = false) {
$php = (PHP_VERSION < 5.3);
if (($php && $part) || Multibyte::checkMultibyte($haystack)) {
$check = Multibyte::strtoupper($haystack);
$check = Multibyte::utf8($check);
$found = false;
$haystack = Multibyte::utf8($haystack);
$haystackCount = count($haystack);
$needle = Multibyte::strtoupper($needle);
$needle = Multibyte::utf8($needle);
$needleCount = count($needle);
$parts = array();
$position = 0;
while (($found === false) && ($position < $haystackCount)) {
if (isset($needle[0]) && $needle[0] === $check[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $check[$position + $i]) {
break;
}
}
if ($i === $needleCount) {
$found = true;
}
}
if (!$found) {
$parts[] = $haystack[$position];
unset($haystack[$position]);
}
$position++;
}
if ($found && $part && !empty($parts)) {
return Multibyte::ascii($parts);
} elseif ($found && !empty($haystack)) {
return Multibyte::ascii($haystack);
}
return false;
}
if (!$php) {
return stristr($haystack, $needle, $part);
}
return stristr($haystack, $needle);
}
/**
* Get string length.
*
* @param string $string The string being checked for length.
* @return integer The number of characters in string $string
* @access public
* @static
*/
function strlen($string) {
if (Multibyte::checkMultibyte($string)) {
$string = Multibyte::utf8($string);
return count($string);
}
return strlen($string);
}
/**
* Find position of first occurrence of a string.
*
* @param string $haystack The string being checked.
* @param string $needle The position counted from the beginning of haystack.
* @param integer $offset The search offset. If it is not specified, 0 is used.
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string.
* If $needle is not found, it returns false.
* @access public
* @static
*/
function strpos($haystack, $needle, $offset = 0) {
if (Multibyte::checkMultibyte($haystack)) {
$found = false;
$haystack = Multibyte::utf8($haystack);
$haystackCount = count($haystack);
$needle = Multibyte::utf8($needle);
$needleCount = count($needle);
$position = $offset;
while (($found === false) && ($position < $haystackCount)) {
if (isset($needle[0]) && $needle[0] === $haystack[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $haystack[$position + $i]) {
break;
}
}
if ($i === $needleCount) {
$found = true;
$position--;
}
}
$position++;
}
if ($found) {
return $position;
}
return false;
}
return strpos($haystack, $needle, $offset);
}
/**
* Finds the last occurrence of a character in a string within another.
*
* @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
* If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
* Default value is false.
* @return string|boolean The portion of $haystack. or false if $needle is not found.
* @access public
* @static
*/
function strrchr($haystack, $needle, $part = false) {
$check = Multibyte::utf8($haystack);
$found = false;
$haystack = Multibyte::utf8($haystack);
$haystackCount = count($haystack);
$matches = array_count_values($check);
$needle = Multibyte::utf8($needle);
$needleCount = count($needle);
$parts = array();
$position = 0;
while (($found === false) && ($position < $haystackCount)) {
if (isset($needle[0]) && $needle[0] === $check[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $check[$position + $i]) {
if ($needle[$i] === $check[($position + $i) -1]) {
$found = true;
}
unset($parts[$position - 1]);
$haystack = array_merge(array($haystack[$position]), $haystack);
break;
}
}
if (isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) {
$matches[$needle[0]] = $matches[$needle[0]] - 1;
} elseif ($i === $needleCount) {
$found = true;
}
}
if (!$found && isset($haystack[$position])) {
$parts[] = $haystack[$position];
unset($haystack[$position]);
}
$position++;
}
if ($found && $part && !empty($parts)) {
return Multibyte::ascii($parts);
} elseif ($found && !empty($haystack)) {
return Multibyte::ascii($haystack);
}
return false;
}
/**
* Finds the last occurrence of a character in a string within another, case insensitive.
*
* @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
* If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
* Default value is false.
* @return string|boolean The portion of $haystack. or false if $needle is not found.
* @access public
* @static
*/
function strrichr($haystack, $needle, $part = false) {
$check = Multibyte::strtoupper($haystack);
$check = Multibyte::utf8($check);
$found = false;
$haystack = Multibyte::utf8($haystack);
$haystackCount = count($haystack);
$matches = array_count_values($check);
$needle = Multibyte::strtoupper($needle);
$needle = Multibyte::utf8($needle);
$needleCount = count($needle);
$parts = array();
$position = 0;
while (($found === false) && ($position < $haystackCount)) {
if (isset($needle[0]) && $needle[0] === $check[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $check[$position + $i]) {
if ($needle[$i] === $check[($position + $i) -1]) {
$found = true;
}
unset($parts[$position - 1]);
$haystack = array_merge(array($haystack[$position]), $haystack);
break;
}
}
if (isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) {
$matches[$needle[0]] = $matches[$needle[0]] - 1;
} elseif ($i === $needleCount) {
$found = true;
}
}
if (!$found && isset($haystack[$position])) {
$parts[] = $haystack[$position];
unset($haystack[$position]);
}
$position++;
}
if ($found && $part && !empty($parts)) {
return Multibyte::ascii($parts);
} elseif ($found && !empty($haystack)) {
return Multibyte::ascii($haystack);
}
return false;
}
/**
* Finds position of last occurrence of a string within another, case insensitive
*
* @param string $haystack The string from which to get the position of the last occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching.
* @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string,
* or false if $needle is not found.
* @access public
* @static
*/
function strripos($haystack, $needle, $offset = 0) {
if (!PHP5 || Multibyte::checkMultibyte($haystack)) {
$found = false;
$haystack = Multibyte::strtoupper($haystack);
$haystack = Multibyte::utf8($haystack);
$haystackCount = count($haystack);
$matches = array_count_values($haystack);
$needle = Multibyte::strtoupper($needle);
$needle = Multibyte::utf8($needle);
$needleCount = count($needle);
$position = $offset;
while (($found === false) && ($position < $haystackCount)) {
if (isset($needle[0]) && $needle[0] === $haystack[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $haystack[$position + $i]) {
if ($needle[$i] === $haystack[($position + $i) -1]) {
$position--;
$found = true;
continue;
}
}
}
if (!$offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) {
$matches[$needle[0]] = $matches[$needle[0]] - 1;
} elseif ($i === $needleCount) {
$found = true;
$position--;
}
}
$position++;
}
return ($found) ? $position : false;
}
return strripos($haystack, $needle, $offset);
}
/**
* Find position of last occurrence of a string in a string.
*
* @param string $haystack The string being checked, for the last occurrence of $needle.
* @param string $needle The string to find in $haystack.
* @param integer $offset May be specified to begin searching an arbitrary number of characters into the string.
* Negative values will stop searching at an arbitrary point prior to the end of the string.
* @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string.
* If $needle is not found, it returns false.
* @access public
* @static
*/
function strrpos($haystack, $needle, $offset = 0) {
if (!PHP5 || Multibyte::checkMultibyte($haystack)) {
$found = false;
$haystack = Multibyte::utf8($haystack);
$haystackCount = count($haystack);
$matches = array_count_values($haystack);
$needle = Multibyte::utf8($needle);
$needleCount = count($needle);
$position = $offset;
while (($found === false) && ($position < $haystackCount)) {
if (isset($needle[0]) && $needle[0] === $haystack[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $haystack[$position + $i]) {
if ($needle[$i] === $haystack[($position + $i) -1]) {
$position--;
$found = true;
continue;
}
}
}
if (!$offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) {
$matches[$needle[0]] = $matches[$needle[0]] - 1;
} elseif ($i === $needleCount) {
$found = true;
$position--;
}
}
$position++;
}
return ($found) ? $position : false;
}
return strrpos($haystack, $needle, $offset);
}
/**
* Finds first occurrence of a string within another
*
* @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack
* @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
* Default value is FALSE.
* @return string|boolean The portion of $haystack, or true if $needle is not found.
* @access public
* @static
*/
function strstr($haystack, $needle, $part = false) {
$php = (PHP_VERSION < 5.3);
if (($php && $part) || Multibyte::checkMultibyte($haystack)) {
$check = Multibyte::utf8($haystack);
$found = false;
$haystack = Multibyte::utf8($haystack);
$haystackCount = count($haystack);
$needle = Multibyte::utf8($needle);
$needleCount = count($needle);
$parts = array();
$position = 0;
while (($found === false) && ($position < $haystackCount)) {
if (isset($needle[0]) && $needle[0] === $check[$position]) {
for ($i = 1; $i < $needleCount; $i++) {
if ($needle[$i] !== $check[$position + $i]) {
break;
}
}
if ($i === $needleCount) {
$found = true;
}
}
if (!$found) {
$parts[] = $haystack[$position];
unset($haystack[$position]);
}
$position++;
}
if ($found && $part && !empty($parts)) {
return Multibyte::ascii($parts);
} elseif ($found && !empty($haystack)) {
return Multibyte::ascii($haystack);
}
return false;
}
if (!$php) {
return strstr($haystack, $needle, $part);
}
return strstr($haystack, $needle);
}
/**
* Make a string lowercase
*
* @param string $string The string being lowercased.
* @return string with all alphabetic characters converted to lowercase.
* @access public
* @static
*/
function strtolower($string) {
$_this =& Multibyte::getInstance();
$utf8Map = Multibyte::utf8($string);
$length = count($utf8Map);
$lowerCase = array();
$matched = false;
for ($i = 0 ; $i < $length; $i++) {
$char = $utf8Map[$i];
if ($char < 128) {
$str = strtolower(chr($char));
$strlen = strlen($str);
for ($ii = 0 ; $ii < $strlen; $ii++) {
$lower = ord(substr($str, $ii, 1));
}
$lowerCase[] = $lower;
$matched = true;
} else {
$matched = false;
$keys = $_this->__find($char, 'upper');
if (!empty($keys)) {
foreach ($keys as $key => $value) {
if ($keys[$key]['upper'] == $char && count($keys[$key]['lower'][0]) === 1) {
$lowerCase[] = $keys[$key]['lower'][0];
$matched = true;
break 1;
}
}
}
}
if ($matched === false) {
$lowerCase[] = $char;
}
}
return Multibyte::ascii($lowerCase);
}
/**
* Make a string uppercase
*
* @param string $string The string being uppercased.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string with all alphabetic characters converted to uppercase.
* @access public
* @static
*/
function strtoupper($string) {
$_this =& Multibyte::getInstance();
$utf8Map = Multibyte::utf8($string);
$length = count($utf8Map);
$matched = false;
$replaced = array();
$upperCase = array();
for ($i = 0 ; $i < $length; $i++) {
$char = $utf8Map[$i];
if ($char < 128) {
$str = strtoupper(chr($char));
$strlen = strlen($str);
for ($ii = 0 ; $ii < $strlen; $ii++) {
$upper = ord(substr($str, $ii, 1));
}
$upperCase[] = $upper;
$matched = true;
} else {
$matched = false;
$keys = $_this->__find($char);
$keyCount = count($keys);
if (!empty($keys)) {
foreach ($keys as $key => $value) {
$matched = false;
$replace = 0;
if ($length > 1 && count($keys[$key]['lower']) > 1) {
$j = 0;
for ($ii = 0, $count = count($keys[$key]['lower']); $ii < $count; $ii++) {
$nextChar = $utf8Map[$i + $ii];
if (isset($nextChar) && ($nextChar == $keys[$key]['lower'][$j + $ii])) {
$replace++;
}
}
if ($replace == $count) {
$upperCase[] = $keys[$key]['upper'];
$replaced = array_merge($replaced, array_values($keys[$key]['lower']));
$matched = true;
break 1;
}
} elseif ($length > 1 && $keyCount > 1) {
$j = 0;
for ($ii = 1; $ii < $keyCount; $ii++) {
$nextChar = $utf8Map[$i + $ii - 1];
if (in_array($nextChar, $keys[$ii]['lower'])) {
for ($jj = 0, $count = count($keys[$ii]['lower']); $jj < $count; $jj++) {
$nextChar = $utf8Map[$i + $jj];
if (isset($nextChar) && ($nextChar == $keys[$ii]['lower'][$j + $jj])) {
$replace++;
}
}
if ($replace == $count) {
$upperCase[] = $keys[$ii]['upper'];
$replaced = array_merge($replaced, array_values($keys[$ii]['lower']));
$matched = true;
break 2;
}
}
}
}
if ($keys[$key]['lower'][0] == $char) {
$upperCase[] = $keys[$key]['upper'];
$matched = true;
break 1;
}
}
}
}
if ($matched === false && !in_array($char, $replaced, true)) {
$upperCase[] = $char;
}
}
return Multibyte::ascii($upperCase);
}
/**
* Count the number of substring occurrences
*
* @param string $haystack The string being checked.
* @param string $needle The string being found.
* @return integer The number of times the $needle substring occurs in the $haystack string.
* @access public
* @static
*/
function substrCount($haystack, $needle) {
$count = 0;
$haystack = Multibyte::utf8($haystack);
$haystackCount = count($haystack);
$matches = array_count_values($haystack);
$needle = Multibyte::utf8($needle);
$needleCount = count($needle);
if ($needleCount === 1 && isset($matches[$needle[0]])) {
return $matches[$needle[0]];
}
for ($i = 0; $i < $haystackCount; $i++) {
if (isset($needle[0]) && $needle[0] === $haystack[$i]) {
for ($ii = 1; $ii < $needleCount; $ii++) {
if ($needle[$ii] === $haystack[$i + 1]) {
if ((isset($needle[$ii + 1]) && $haystack[$i + 2]) && $needle[$ii + 1] !== $haystack[$i + 2]) {
$count--;
} else {
$count++;
}
}
}
}
}
return $count;
}
/**
* Get part of string
*
* @param string $string The string being checked.
* @param integer $start The first position used in $string.
* @param integer $length The maximum length of the returned string.
* @return string The portion of $string specified by the $string and $length parameters.
* @access public
* @static
*/
function substr($string, $start, $length = null) {
if ($start === 0 && $length === null) {
return $string;
}
$string = Multibyte::utf8($string);
$stringCount = count($string);
for ($i = 1; $i <= $start; $i++) {
unset($string[$i - 1]);
}
if ($length === null || count($string) < $length) {
return Multibyte::ascii($string);
}
$string = array_values($string);
$value = array();
for ($i = 0; $i < $length; $i++) {
$value[] = $string[$i];
}
return Multibyte::ascii($value);
}
/**
* Prepare a string for mail transport, using the provided encoding
*
* @param string $string value to encode
* @param string $charset charset to use for encoding. defaults to UTF-8
* @param string $newline
* @return string
* @access public
* @static
* @TODO: add support for 'Q'('Quoted Printable') encoding
*/
function mimeEncode($string, $charset = null, $newline = "\r\n") {
if (!Multibyte::checkMultibyte($string) && strlen($string) < 75) {
return $string;
}
if (empty($charset)) {
$charset = Configure::read('App.encoding');
}
$charset = strtoupper($charset);
$start = '=?' . $charset . '?B?';
$end = '?=';
$spacer = $end . $newline . ' ' . $start;
$length = 75 - strlen($start) - strlen($end);
$length = $length - ($length % 4);
if ($charset == 'UTF-8') {
$parts = array();
$maxchars = floor(($length * 3) / 4);
while (strlen($string) > $maxchars) {
$i = $maxchars;
$test = ord($string[$i]);
while ($test >= 128 && $test <= 191) {
$i--;
$test = ord($string[$i]);
}
$parts[] = base64_encode(substr($string, 0, $i));
$string = substr($string, $i);
}
$parts[] = base64_encode($string);
$string = implode($spacer, $parts);
} else {
$string = chunk_split(base64_encode($string), $length, $spacer);
$string = preg_replace('/' . preg_quote($spacer) . '$/', '', $string);
}
return $start . $string . $end;
}
/**
* Return the Code points range for Unicode characters
*
* @param interger $decimal
* @return string
* @access private
*/
function __codepoint($decimal) {
if ($decimal > 128 && $decimal < 256) {
$return = '0080_00ff'; // Latin-1 Supplement
} elseif ($decimal < 384) {
$return = '0100_017f'; // Latin Extended-A
} elseif ($decimal < 592) {
$return = '0180_024F'; // Latin Extended-B
} elseif ($decimal < 688) {
$return = '0250_02af'; // IPA Extensions
} elseif ($decimal >= 880 && $decimal < 1024) {
$return = '0370_03ff'; // Greek and Coptic
} elseif ($decimal < 1280) {
$return = '0400_04ff'; // Cyrillic
} elseif ($decimal < 1328) {
$return = '0500_052f'; // Cyrillic Supplement
} elseif ($decimal < 1424) {
$return = '0530_058f'; // Armenian
} elseif ($decimal >= 7680 && $decimal < 7936) {
$return = '1e00_1eff'; // Latin Extended Additional
} elseif ($decimal < 8192) {
$return = '1f00_1fff'; // Greek Extended
} elseif ($decimal >= 8448 && $decimal < 8528) {
$return = '2100_214f'; // Letterlike Symbols
} elseif ($decimal < 8592) {
$return = '2150_218f'; // Number Forms
} elseif ($decimal >= 9312 && $decimal < 9472) {
$return = '2460_24ff'; // Enclosed Alphanumerics
} elseif ($decimal >= 11264 && $decimal < 11360) {
$return = '2c00_2c5f'; // Glagolitic
} elseif ($decimal < 11392) {
$return = '2c60_2c7f'; // Latin Extended-C
} elseif ($decimal < 11520) {
$return = '2c80_2cff'; // Coptic
} elseif ($decimal >= 65280 && $decimal < 65520) {
$return = 'ff00_ffef'; // Halfwidth and Fullwidth Forms
} else {
$return = false;
}
$this->__codeRange[$decimal] = $return;
return $return;
}
/**
* Find the related code folding values for $char
*
* @param integer $char decimal value of character
* @param string $type
* @return array
* @access private
*/
function __find($char, $type = 'lower') {
$value = false;
$found = array();
if (!isset($this->__codeRange[$char])) {
$range = $this->__codepoint($char);
if ($range === false) {
return null;
}
Configure::load('unicode' . DS . 'casefolding' . DS . $range);
$this->__caseFold[$range] = Configure::read($range);
Configure::delete($range);
}
if (!$this->__codeRange[$char]) {
return null;
}
$this->__table = $this->__codeRange[$char];
$count = count($this->__caseFold[$this->__table]);
for ($i = 0; $i < $count; $i++) {
if ($type === 'lower' && $this->__caseFold[$this->__table][$i][$type][0] === $char) {
$found[] = $this->__caseFold[$this->__table][$i];
} elseif ($type === 'upper' && $this->__caseFold[$this->__table][$i][$type] === $char) {
$found[] = $this->__caseFold[$this->__table][$i];
}
}
return $found;
}
/**
* Check the $string for multibyte characters
* @param string $string value to test
* @return boolean
* @access public
* @static
*/
function checkMultibyte($string) {
$length = strlen($string);
for ($i = 0; $i < $length; $i++ ) {
$value = ord(($string[$i]));
if ($value > 128) {
return true;
}
}
return false;
}
}
?>