# Rewrite clean URLs onto real files
<IfModule mod_rewrite.c>
-Options +FollowSymlinks
-<IfDefine APACHE2>
+ <IfDefine APACHE2>
AcceptPathInfo On
-</IfDefine>
-RewriteEngine On
-RewriteBase /
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteCond %{REQUEST_FILENAME}.php -f
-RewriteRule ^([^/]+)/?(.*) $1.php/$2 [L]
+ </IfDefine>
+ RewriteEngine On
+ RewriteBase /
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME}.php -f
+ RewriteRule ^([^/]+)/?(.*) $1.php/$2 [L]
</IfModule>
-Scuttle contains code from the following applications:
+Scuttle contains code from the following open-source projects:
-------------
-GPL Licenced
-------------
+jQuery
+http://www.jquery.com/
phpBB2 (database abstraction layer)
http://www.phpbb.com/
Danilo Segan <danilo@kvota.net>
http://savannah.nongnu.org/projects/php-gettext/
-UTF8 Helper Functions
-Andreas Gohr <andi@splitbrain.org>
+PHP UTF-8
+https://sourceforge.net/projects/phputf8/
XSPF Web Music Player (Flash)
http://musicplayer.sourceforge.net/
\ No newline at end of file
<?php
/***************************************************************************
-Copyright (C) 2004, 2005 Scuttle project
+Copyright (c) 2004 - 2010 Scuttle project
http://sourceforge.net/projects/scuttle/
This program is free software; you can redistribute it and/or modify
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
-require_once('header.inc.php');
+require_once 'header.inc.php';
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
-$tplVars = array();
+$tplVars = array();
$tplVars['subtitle'] = T_('About');
$templateservice->loadTemplate('about.tpl', $tplVars);
-?>
\ No newline at end of file
<?php
/***************************************************************************
-Copyright (C) 2005 - 2006 Scuttle project
+Copyright (c) 2005 - 2010 Scuttle project
http://sourceforge.net/projects/scuttle/
http://scuttle.org/
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
-header('Content-Type: text/xml; charset=UTF-8');
+header('Content-Type: text/plain; charset=UTF-8');
header('Last-Modified: '. gmdate("D, d M Y H:i:s") .' GMT');
header('Cache-Control: no-cache, must-revalidate');
-require_once('header.inc.php');
+require_once 'header.inc.php';
-$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
+$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
$bookmark = intval($_GET['id']);
if (!$bookmarkservice->editAllowed($bookmark)) {
- $result = T_('You are not allowed to delete this bookmark');
+ echo T_('You are not allowed to delete this bookmark');
} elseif ($bookmarkservice->deleteBookmark($bookmark)) {
- $result = 'true';
+ echo true;
} else {
- $result = T_('Failed to delete bookmark');
+ echo T_('Failed to delete bookmark');
}
-?>
-<response>
- <method>deleteConfirmed</method>
- <result><?php echo $result; ?></result>
-</response>
\ No newline at end of file
<?php
/***************************************************************************
-Copyright (C) 2005 - 2006 Scuttle project
+Copyright (c) 2005 - 2010 Scuttle project
http://sourceforge.net/projects/scuttle/
http://scuttle.org/
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
-header('Content-Type: text/xml; charset=UTF-8');
-header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
-header("Cache-Control: no-cache, must-revalidate");
-
-require_once('header.inc.php');
+header('Content-Type: text/plain; charset=UTF-8');
+header('Last-Modified: '. gmdate("D, d M Y H:i:s") .' GMT');
+header('Cache-Control: no-cache, must-revalidate');
+require_once 'header.inc.php';
function getTitle($url) {
$fd = @fopen($url, 'r');
return false;
}
}
-echo '<?xml version="1.0" encoding="utf-8"?>';
-?>
-<response>
- <method>getTitle</method>
- <result><?php echo getTitle($_GET['url']); ?></result>
-</response>
\ No newline at end of file
+echo getTitle($_GET['url']);
<?php
/***************************************************************************
-Copyright (C) 2006 Scuttle project
+Copyright (c) 2006 - 2010 Scuttle project
http://sourceforge.net/projects/scuttle/
http://scuttle.org/
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
-header('Content-Type: text/xml; charset=UTF-8');
-header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
-header("Cache-Control: no-cache, must-revalidate");
+header('Content-Type: text/plain; charset=UTF-8');
+header('Last-Modified: '. gmdate("D, d M Y H:i:s") .' GMT');
+header('Cache-Control: no-cache, must-revalidate');
+require_once 'header.inc.php';
-require_once('header.inc.php');
-$userservice = & ServiceFactory :: getServiceInstance('UserService');
-if ($userservice->isReserved($_GET['username'])) {
- $result = 'false';
-} else {
- $result = $userservice->getUserByUsername($_GET['username']) ? 'false' : 'true';
-}
-?>
-<response>
- <method>isAvailable</method>
- <result><?php echo $result; ?></result>
-</response>
\ No newline at end of file
+$userservice =& ServiceFactory::getServiceInstance('UserService');
+echo !($userservice->isReserved($_GET['username']) || $userservice->getUserByUsername($_GET['username']));
<?php
/***************************************************************************
-Copyright (C) 2004 - 2006 Scuttle project
+Copyright (c) 2004 - 2006 Scuttle project
http://sourceforge.net/projects/scuttle/
http://scuttle.org/
<?php
/***************************************************************************
-Copyright (C) 2004 - 2006 Scuttle project
+Copyright (c) 2004 - 2006 Scuttle project
http://sourceforge.net/projects/scuttle/
http://scuttle.org/
######################################################################
# SCUTTLE: Online social bookmarks manager
######################################################################
-# Copyright (C) 2005 - 2006 Scuttle project
+# Copyright (c) 2005 - 2010 Scuttle project
# http://sourceforge.net/projects/scuttle/
# http://scuttle.org/
#
);
$reservedusers = array('all', 'watchlist');
-include_once('debug.inc.php');
-?>
+include_once 'debug.inc.php';
<?php
/***************************************************************************
-Copyright (C) 2004 - 2006 Scuttle project
+Copyright (c) 2004 - 2006 Scuttle project
http://sourceforge.net/projects/scuttle/
http://scuttle.org/
<?php
// UTF-8 functions
-require_once(dirname(__FILE__) .'/includes/utf8.php');
+require_once dirname(__FILE__) .'/includes/utf8/utf8.php';
// Translation
-require_once(dirname(__FILE__) .'/includes/php-gettext/gettext.inc');
+require_once dirname(__FILE__) .'/includes/php-gettext/gettext.inc';
$domain = 'messages';
T_setlocale(LC_ALL, $locale);
T_bindtextdomain($domain, dirname(__FILE__) .'/locales');
echo "<html>\n<body>\n". $msg_title ."\n<br /><br />\n". $msg_text ."</body>\n</html>";
exit;
}
-?>
define('DEBUG', true);
session_start();
-require_once(dirname(__FILE__) .'/services/servicefactory.php');
-require_once(dirname(__FILE__) .'/config.inc.php');
-require_once(dirname(__FILE__) .'/functions.inc.php');
+require_once dirname(__FILE__) .'/services/servicefactory.php';
+require_once dirname(__FILE__) .'/config.inc.php';
+require_once dirname(__FILE__) .'/functions.inc.php';
// Determine the base URL
if (!isset($root)) {
$pieces = explode('/', $_SERVER['SCRIPT_NAME']);
- $root = '/';
- foreach($pieces as $piece) {
+ $root = '/';
+ foreach ($pieces as $piece) {
if ($piece != '' && !strstr($piece, '.php')) {
$root .= $piece .'/';
}
$root .= '/';
}
$path = $root;
- $root = 'http://'. $_SERVER['HTTP_HOST'] . $root;
+
+ $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
+ $root = $protocol .'://'. $_SERVER['HTTP_HOST'] . $root;
}
// Error codes
-define('GENERAL_MESSAGE', 200);
-define('GENERAL_ERROR', 202);
+define('GENERAL_MESSAGE', 200);
+define('GENERAL_ERROR', 202);
define('CRITICAL_MESSAGE', 203);
-define('CRITICAL_ERROR', 204);
-?>
\ No newline at end of file
+define('CRITICAL_ERROR', 204);
<?php
/***************************************************************************
-Copyright (C) 2006 Scuttle project
+Copyright (c) 2006 Scuttle project
http://sourceforge.net/projects/scuttle/
http://scuttle.org/
-<?
+<?php
/***************************************************************************
-Copyright (C) 2004 - 2006 Scuttle project
+Copyright (c) 2004 - 2006 Scuttle project
http://sourceforge.net/projects/scuttle/
http://scuttle.org/
-<?
+<?php
/***************************************************************************
-Copyright (C) 2004 - 2006 Scuttle project
+Copyright (c) 2004 - 2006 Scuttle project
http://sourceforge.net/projects/scuttle/
http://scuttle.org/
--- /dev/null
+/*!
+ * jQuery JavaScript Library v1.4.2
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Sat Feb 13 22:33:48 2010 -0500
+ */
+(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o<i;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,j);return a}return i?
+e(a[0],b):w}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function na(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function oa(a){var b,d=[],f=[],e=arguments,j,i,o,k,n,r;i=c.data(this,"events");if(!(a.liveFired===this||!i||!i.live||a.button&&a.type==="click")){a.liveFired=this;var u=i.live.slice(0);for(k=0;k<u.length;k++){i=u[k];i.origType.replace(O,"")===a.type?f.push(i.selector):u.splice(k--,1)}j=c(a.target).closest(f,a.currentTarget);n=0;for(r=
+j.length;n<r;n++)for(k=0;k<u.length;k++){i=u[k];if(j[n].selector===i.selector){o=j[n].elem;f=null;if(i.preType==="mouseenter"||i.preType==="mouseleave")f=c(a.relatedTarget).closest(i.selector)[0];if(!f||f!==o)d.push({elem:o,handleObj:i})}}n=0;for(r=d.length;n<r;n++){j=d[n];a.currentTarget=j.elem;a.data=j.handleObj.data;a.handleObj=j.handleObj;if(j.handleObj.origHandler.apply(j.elem,e)===false){b=false;break}}return b}}function pa(a,b){return"live."+(a&&a!=="*"?a+".":"")+b.replace(/\./g,"`").replace(/ /g,
+"&")}function qa(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function ra(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var j in f)for(var i in f[j])c.event.add(this,j,f[j][i],f[j][i].data)}}})}function sa(a,b,d){var f,e,j;b=b&&b[0]?b[0].ownerDocument||b[0]:s;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===s&&!ta.test(a[0])&&(c.support.checkClone||!ua.test(a[0]))){e=
+true;if(j=c.fragments[a[0]])if(j!==1)f=j}if(!f){f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=j?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ra=A.jQuery,Sa=A.$,s=A.document,T,Ta=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,
+Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&
+(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,
+a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b===
+"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,
+function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(j in e){i=a[j];o=e[j];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){i=i&&(c.isPlainObject(i)||
+c.isArray(i))?i:c.isArray(o)?[]:{};a[j]=c.extend(f,i,o)}else if(o!==w)a[j]=o}return a};c.extend({noConflict:function(a){A.$=Sa;if(a)A.jQuery=Ra;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",
+L,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",L);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&ma()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,
+"isPrototypeOf"))return false;var b;for(b in a);return b===w||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;a=c.trim(a);if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "+
+a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Va.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,j=a.length,i=j===w||c.isFunction(a);if(d)if(i)for(f in a){if(b.apply(a[f],
+d)===false)break}else for(;e<j;){if(b.apply(a[e++],d)===false)break}else if(i)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<j&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Wa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===
+a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,j=a.length;e<j;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,j=0,i=a.length;j<i;j++){e=b(a[j],j,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=w}else if(b&&
+!c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=
+true;if(ya)c.inArray=function(a,b){return ya.call(b,a)};T=c(s);if(s.addEventListener)L=function(){s.removeEventListener("DOMContentLoaded",L,false);c.ready()};else if(s.attachEvent)L=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,
+parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent=
+false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n=
+s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,
+applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando];
+else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,
+a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===
+w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,
+cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className){for(var j=" "+e.className+" ",
+i=e.className,o=0,k=b.length;o<k;o++)if(j.indexOf(" "+b[o]+" ")<0)i+=" "+b[o];e.className=c.trim(i)}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(k){var n=c(this);n.removeClass(a.call(this,k,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var j=(" "+e.className+" ").replace(Aa," "),i=0,o=b.length;i<o;i++)j=j.replace(" "+b[i]+" ",
+" ");e.className=c.trim(j)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var j=c(this);j.toggleClass(a.call(this,e,j.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,j=0,i=c(this),o=b,k=a.split(ca);e=k[j++];){o=f?o:!i.hasClass(e);i[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=
+this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(Aa," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j<d;j++){var i=
+e[j];if(i.selected){a=c(i).val();if(b)return a;f.push(a)}}return f}if(Ba.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Za,"")}return w}var o=c.isFunction(a);return this.each(function(k){var n=c(this),r=a;if(this.nodeType===1){if(o)r=a.call(this,k,n.val());if(typeof r==="number")r+="";if(c.isArray(r)&&Ba.test(this.type))this.checked=c.inArray(n.val(),r)>=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected=
+c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");
+a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,
+function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split(".");
+k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a),
+C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B<r.length;B++){u=r[B];if(d.guid===u.guid){if(i||k.test(u.namespace)){f==null&&r.splice(B--,1);n.remove&&n.remove.call(a,u)}if(f!=
+null)break}}if(r.length===0||f!=null&&r.length===1){if(!n.teardown||n.teardown.call(a,o)===false)Ca(a,e,z.handle);delete C[e]}}else for(var B=0;B<r.length;B++){u=r[B];if(i||k.test(u.namespace)){c.event.remove(a,n,u.handler,B);r.splice(B--,1)}}}if(c.isEmptyObject(C)){if(b=z.handle)b.elem=null;delete z.events;delete z.handle;c.isEmptyObject(z)&&c.removeData(a)}}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=
+e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&&
+f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;
+if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e<j;e++){var i=d[e];if(b||f.test(i.namespace)){a.handler=i.handler;a.data=i.data;a.handleObj=i;i=i.handler.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
+d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,a.origType,c.extend({},a,{handler:oa}))},remove:function(a){var b=true,d=a.origType.replace(O,"");c.each(c.data(this,
+"events").live||[],function(){if(d===this.origType.replace(O,""))return b=false});b&&c.event.remove(this,a.origType,oa)}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};var Ca=s.removeEventListener?function(a,b,d){a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=
+a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,
+isImmediatePropagationStopped:Y};var Da=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},Ea=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ea:Da,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ea:Da)}}});if(!c.support.submitBubbles)c.event.special.submit=
+{setup:function(){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length)return na("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13)return na("submit",this,arguments)})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};
+if(!c.support.changeBubbles){var da=/textarea|input|select/i,ea,Fa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",
+e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,
+"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,
+d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j<o;j++)c.event.add(this[j],d,i,f)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&
+!a.preventDefault)for(var d in a)this.unbind(d,a[d]);else{d=0;for(var f=this.length;d<f;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,f){return this.live(b,d,f,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},
+toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var Ga={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e,j){var i,o=0,k,n,r=j||this.selector,
+u=j?this:c(this.context);if(c.isFunction(f)){e=f;f=w}for(d=(d||"").split(" ");(i=d[o++])!=null;){j=O.exec(i);k="";if(j){k=j[0];i=i.replace(O,"")}if(i==="hover")d.push("mouseenter"+k,"mouseleave"+k);else{n=i;if(i==="focus"||i==="blur"){d.push(Ga[i]+k);i+=k}else i=(Ga[i]||i)+k;b==="live"?u.each(function(){c.event.add(this,pa(i,r),{data:f,selector:r,handler:e,origType:i,origHandler:e,preType:n})}):u.unbind(pa(i,r),e)}}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),
+function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",l,m=0;g[m];m++){l=g[m];if(l.nodeType===3||l.nodeType===4)h+=l.nodeValue;else if(l.nodeType!==8)h+=a(l.childNodes)}return h}function b(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];
+if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=l;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}m[q]=y}}}function d(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=l;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(k.filter(h,[t]).length>0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift();
+t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D||
+g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};k.matches=function(g,h){return k(g,null,null,h)};k.find=function(g,h,l){var m,q;if(!g)return[];
+for(var p=0,v=n.order.length;p<v;p++){var t=n.order[p];if(q=n.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");m=n.find[t](q,h,l);if(m!=null){g=g.replace(n.match[t],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};k.filter=function(g,h,l,m){for(var q=g,p=[],v=h,t,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var H in n.filter)if((t=n.leftMatch[H].exec(g))!=null&&t[2]){var M=n.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-
+1)!=="\\"){if(v===p)p=[];if(n.preFilter[H])if(t=n.preFilter[H](t,v,l,p,m,S)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=v[U])!=null;U++)if(D){I=M(D,t,U,v);var Ha=m^!!I;if(l&&I!=null)if(Ha)y=true;else v[U]=false;else if(Ha){p.push(D);y=true}}if(I!==w){l||(v=p);g=g.replace(n.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)k.error(g);else break;q=g}return v};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var n=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},
+relative:{"+":function(g,h){var l=typeof h==="string",m=l&&!/\W/.test(h);l=l&&!m;if(m)h=h.toLowerCase();m=0;for(var q=g.length,p;m<q;m++)if(p=g[m]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[m]=l||p&&p.nodeName.toLowerCase()===h?p||false:p===h}l&&k.filter(h,g,true)},">":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m<q;m++){var p=g[m];if(p){l=p.parentNode;g[m]=l.nodeName.toLowerCase()===h?l:false}}}else{m=0;for(q=g.length;m<q;m++)if(p=g[m])g[m]=
+l?p.parentNode:p.parentNode===h;l&&k.filter(h,g,true)}},"":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("parentNode",h,m,g,p,l)},"~":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,m,g,p,l)}},find:{ID:function(g,h,l){if(typeof h.getElementById!=="undefined"&&!l)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var l=[];
+h=h.getElementsByName(g[1]);for(var m=0,q=h.length;m<q;m++)h[m].getAttribute("name")===g[1]&&l.push(h[m]);return l.length===0?null:l}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,l,m,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var v;(v=h[p])!=null;p++)if(v)if(q^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},
+CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m,
+g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},
+text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},
+setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return h<l[3]-0},gt:function(g,h,l){return h>l[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=
+h[3];l=0;for(m=h.length;l<m;l++)if(h[l]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+q)},CHILD:function(g,h){var l=h[1],m=g;switch(l){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(l==="first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":l=h[2];var q=h[3];if(l===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var v=0;for(m=p.firstChild;m;m=
+m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;p.sizcache=h}g=g.nodeIndex-q;return l===0?g===0:g%l===0&&g/l>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===
+"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g,
+h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l<m;l++)h.push(g[l]);else for(l=0;g[l];l++)h.push(g[l]);return h}}var B;if(s.documentElement.compareDocumentPosition)B=function(g,h){if(!g.compareDocumentPosition||
+!h.compareDocumentPosition){if(g==h)i=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)i=true;return g};else if("sourceIndex"in s.documentElement)B=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)i=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)i=true;return g};else if(s.createRange)B=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)i=true;return g.ownerDocument?-1:1}var l=g.ownerDocument.createRange(),m=
+h.ownerDocument.createRange();l.setStart(g,0);l.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=l.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)i=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&&
+q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML="<a href='#'></a>";
+if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}();
+(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:
+function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)k(g,h[q],l);return k.filter(m,l)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=a;c.isXMLDoc=x;c.contains=E})();var eb=/Until$/,fb=/^(?:parents|prevUntil|prevAll)/,
+gb=/,/;R=Array.prototype.slice;var Ia=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,j){return!!b.call(e,j,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Ua.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;
+c.find(a,this[f],b);if(f>0)for(var j=d;j<b.length;j++)for(var i=0;i<d;i++)if(b[i]===b[j]){b.splice(j--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ia(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ia(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j=
+{},i;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){i=a[e];j[i]||(j[i]=c.expr.match.POS.test(i)?c(i,b||this.context):i)}for(;f&&f.ownerDocument&&f!==b;){for(i in j){e=j[i];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a===
+"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",
+d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?
+a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType===
+1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/<tbody/i,jb=/<|&#?\w+;/,ta=/<script|<object|<embed|<option|<style/i,ua=/checked\s*(?:[^=]|=\s*.checked.)/i,Ma=function(a,b,d){return hb.test(d)?
+a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=
+c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
+wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},
+prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,
+this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);
+return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja,
+""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var j=c(this),i=j.html();j.empty().append(function(){return a.call(this,e,i)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&
+this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,b,f))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(u){return c.nodeName(u,"table")?u.getElementsByTagName("tbody")[0]||
+u.appendChild(u.ownerDocument.createElement("tbody")):u}var e,j,i=a[0],o=[],k;if(!c.support.checkClone&&arguments.length===3&&typeof i==="string"&&ua.test(i))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(i))return this.each(function(u){var z=c(this);a[0]=i.call(this,u,b?z.html():w);z.domManip(a,b,d)});if(this[0]){e=i&&i.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:sa(a,this,o);k=e.fragment;if(j=k.childNodes.length===
+1?(k=k.firstChild):k.firstChild){b=b&&c.nodeName(j,"tr");for(var n=0,r=this.length;n<r;n++)d.call(b?f(this[n],j):this[n],n>0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]);
+return this}else{e=0;for(var j=d.length;e<j;e++){var i=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["",
+""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]==="<table>"&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e=
+c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]?
+c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja=
+function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=
+Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,
+"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=
+a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=
+a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/<script(.|\s)*?\/script>/gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!==
+"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("<div />").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this},
+serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),
+function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,
+global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&
+e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)?
+"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===
+false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B=
+false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",
+c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E||
+d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x);
+g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===
+1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b===
+"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional;
+if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");
+this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],
+"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},
+animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.replace(ia,ja);if(i!==n){a[n]=a[i];delete a[i];i=n}if(a[i]==="hide"&&o||a[i]==="show"&&!o)return j.complete.call(this);if((i==="height"||i==="width")&&this.style){j.display=c.css(this,"display");j.overflow=this.style.overflow}if(c.isArray(a[i])){(j.specialEasing=
+j.specialEasing||{})[i]=a[i][1];a[i]=a[i][0]}}if(j.overflow!=null)this.style.overflow="hidden";j.curAnim=c.extend({},a);c.each(a,function(r,u){var z=new c.fx(k,j,r);if(Ab.test(u))z[u==="toggle"?o?"show":"hide":u](a);else{var C=Bb.exec(u),B=z.cur(true)||0;if(C){u=parseFloat(C[2]);var E=C[3]||"px";if(E!=="px"){k.style[r]=(u||1)+E;B=(u||1)/z.cur(true)*B;k.style[r]=B+E}if(C[1])u=(C[1]==="-="?-1:1)*u+B;z.custom(B,u,E)}else z.custom(B,u,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);
+this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration===
+"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||
+c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;
+this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=
+this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,
+e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||
+c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?
+function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=
+this[0];if(a)return this.each(function(r){c.offset.setOffset(this,a,r)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=b,e=b.ownerDocument,j,i=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var k=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==i;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;j=e?e.getComputedStyle(b,null):b.currentStyle;
+k-=b.scrollTop;n-=b.scrollLeft;if(b===d){k+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&j.overflow!=="visible"){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=j}if(f.position==="relative"||f.position==="static"){k+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&
+f.position==="fixed"){k+=Math.max(i.scrollTop,o.scrollTop);n+=Math.max(i.scrollLeft,o.scrollLeft)}return{top:k,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),d,f,e,j=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b);
+c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,
+d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-
+f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset":
+"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in
+e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);
+++ /dev/null
-2006-02-07 Danilo Šegan <danilo@gnome.org>
-
- * examples/pigs_dropin.php: comment-out bind_textdomain_codeset
-
- * gettext.inc (T_bind_textdomain_codeset): bind_textdomain_codeset
- is available only in PHP 4.2.0+ (thanks to Jens A. Tkotz).
-
- * Makefile: Include gettext.inc in DIST_FILES, VERSION up to
- 1.0.7.
-
-2006-02-03 Danilo Šegan <danilo@gnome.org>
-
- Added setlocale() emulation as well.
-
- * examples/pigs_dropin.php: Use T_setlocale() and locale_emulation().
- * examples/pigs_fallback.php: Use T_setlocale() and locale_emulation().
-
- * gettext.inc: Added globals $EMULATEGETTEXT and $CURRENTLOCALE.
- (locale_emulation): Whether emulation is active.
- (_check_locale): Rewrite.
- (_setlocale): Added emulated setlocale function.
- (T_setlocale): Wrapper around _setlocale.
- (_get_reader): Use variables and _setlocale.
-
-2006-02-02 Danilo Šegan <danilo@gnome.org>
-
- Fix bug #12192.
-
- * examples/locale/sr_CS/LC_MESSAGES/messages.po: Correct grammar.
- * examples/locale/sr_CS/LC_MESSAGES/messages.mo: Rebuild.
-
-2006-02-02 Danilo Šegan <danilo@gnome.org>
-
- Fix bug #15419.
-
- * streams.php: Support for PHP 5.1.1 fread() which reads most 8kb.
- (Fix by Piotr Szotkowski <shot@hot.pl>)
-
-2006-02-02 Danilo Šegan <danilo@gnome.org>
-
- Merge Steven Armstrong's changes, supporting standard gettext
- interfaces:
-
- * examples/*: Restructured examples.
- * gettext.inc: Added.
- * AUTHORS: Added Steven.
- * Makefile (VERSION): Up to 1.0.6.
-
-2006-01-28 Nico Kaiser <nico@siriux.net>
-
- * gettext.php (select_string): Fix "true" <-> 1 difference of PHP
-
-2005-07-29 Danilo Šegan <danilo@gnome.org>
-
- * Makefile (VERSION): Up to 1.0.5.
-
-2005-07-29 Danilo Šegan <danilo@gnome.org>
-
- Fixes bug #13850.
-
- * gettext.php (gettext_reader): check $Reader->error as well.
-
-2005-07-29 Danilo Šegan <danilo@gnome.org>
-
- * Makefile (VERSION): Up to 1.0.4.
-
-2005-07-29 Danilo Šegan <danilo@gnome.org>
-
- Fixes bug #13771.
-
- * gettext.php (gettext_reader->get_plural_forms): Plural forms
- header extraction regex change. Reported by Edgar Gonzales.
-
-2005-02-28 Danilo Šegan <dsegan@gmx.net>
-
- * AUTHORS: Added Nico to the list.
-
- * Makefile (VERSION): Up to 1.0.3.
-
- * README: Updated.
-
-2005-02-28 Danilo Šegan <dsegan@gmx.net>
-
- * gettext.php: Added pre-loading, code documentation, and many
- code clean-ups by Nico Kaiser <nico@siriux.net>.
-
-2005-02-28 Danilo Šegan <dsegan@gmx.net>
-
- * streams.php (FileReader.read): Handle read($bytes = 0).
-
- * examples/pigs.php: Prefix gettext function names with T or T_.
-
- * examples/update: Use the same keywords T_ and T_ngettext.
-
- * streams.php: Added CachedFileReader.
-
-2003-11-11 Danilo Šegan <dsegan@gmx.net>
-
- * gettext.php: Added hashing to find_string.
-
-2003-11-01 Danilo Šegan <dsegan@gmx.net>
-
- * Makefile (DIST_FILES): Replaced LICENSE with COPYING.
- (VERSION): Up to 1.0.2.
-
- * AUTHORS: Minor edits.
-
- * README: Minor edits.
-
- * COPYING: Removed LICENSE, added this file.
-
- * gettext.php: Added copyright notice and disclaimer.
- * streams.php: Same.
- * examples/pigs.php: Same.
-
-2003-10-23 Danilo Šegan <dsegan@gmx.net>
-
- * Makefile: Upped version to 1.0.1.
-
- * gettext.php (gettext_reader): Remove a call to set_total_plurals.
- (set_total_plurals): Removed unused function for some better days.
-
-2003-10-23 Danilo Šegan <dsegan@gmx.net>
-
- * Makefile: Added, version 1.0.0.
-
- * examples/*: Added an example of usage.
-
- * README: Described all the crap.
-
-2003-10-22 Danilo Šegan <dsegan@gmx.net>
-
- * gettext.php: Plural forms implemented too.
-
- * streams.php: Added FileReader for direct access to files (no
- need to keep file in memory).
-
- * gettext.php: It works, except for plural forms.
-
- * streams.php: Created abstract class StreamReader.
- Added StringReader class.
-
- * gettext.php: Started writing gettext_reader.
-
PACKAGE = php-gettext-$(VERSION)
-VERSION = 1.0.7
+VERSION = 1.0.10
DIST_FILES = \
gettext.php \
gettext.inc \
streams.php \
AUTHORS \
- ChangeLog \
README \
COPYING \
Makefile \
examples/locale/sr_CS/LC_MESSAGES/messages.mo \
examples/locale/de_CH/LC_MESSAGES/messages.po \
examples/locale/de_CH/LC_MESSAGES/messages.mo \
- examples/update
+ examples/update \
+ tests/LocalesTest.php \
+ tests/ParsingTest.php
-dist:
+check:
+ phpunit --verbose tests
+
+dist: check
if [ -d $(PACKAGE) ]; then \
rm -rf $(PACKAGE); \
fi; \
rm -rf $(PACKAGE); \
fi;
+clean:
+ rm -f $(PACKAGE).tar.gz
-PHP-gettext 1.0
+PHP-gettext 1.0 (https://launchpad.net/php-gettext)
-Copyright 2003, 2006 -- Danilo "angry with PHP[1]" Segan
+Copyright 2003, 2006, 2009 -- Danilo "angry with PHP[1]" Segan
Licensed under GPLv2 (or any later version, see COPYING)
-[1] PHP is actually cyrillic, and translates roughly to
+[1] PHP is actually cyrillic, and translates roughly to
"works-doesn't-work" (UTF-8: Ради-Не-Ради)
file data, I used imaginary abstract class StreamReader to do all
the input (check streams.php). For your convenience, I've already
provided two classes for reading files: FileReader and
- StringReader (CachedFileReader is a combination of the two: it
- loads entire file contents into a string, and then works on that).
- See example below for usage. You can for instance use StringReader
- when you read in data from a database, or you can create your own
- derivative of StreamReader for anything you like.
-
+ StringReader (CachedFileReader is a combination of the two: it
+ loads entire file contents into a string, and then works on that).
+ See example below for usage. You can for instance use StringReader
+ when you read in data from a database, or you can create your own
+ derivative of StreamReader for anything you like.
-Bugs
-
- Plural-forms field in MO header (translation for empty string,
- i.e. "") is treated according to PHP syntactic rules (it's
- eval()ed). Since these should actually follow C syntax, there are
- some problems.
- For instance, I'm used to using this:
- Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : \
- n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
- but it fails with PHP (it sets $plural=2 instead of 0 for $n==1).
-
- The fix is usually simple, but I'm lazy to go into the details of
- PHP operator precedence, and maybe try to fix it. In here, I had
- to put everything after the first ':' in parenthesis:
- Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : \
- (n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);
- That works, and I'm satisfied.
+Bugs
- Besides this one, there are probably a bunch of other bugs, since
- I hate PHP (did I mention it already? no? strange), and don't
- know it very well. So, feel free to fix any of those and report
- them back to me at <danilo@kvota.net>.
+ Report them on https://bugs.launchpad.net/php-gettext
Usage
Then, use that as a parameter to gettext_reader constructor:
$wohoo = new gettext_reader($streamer);
- If you want to disable pre-loading of entire message catalog in
- memory (if, for example, you have a multi-thousand message catalog
- which you'll use only occasionally), use "false" for second
+ If you want to disable pre-loading of entire message catalog in
+ memory (if, for example, you have a multi-thousand message catalog
+ which you'll use only occasionally), use "false" for second
parameter to gettext_reader constructor:
$wohoo = new gettext_reader($streamer, false);
From now on, you have all the benefits of gettext data at your
- disposal, so may run:
+ disposal, so may run:
print $wohoo->translate("This is a test");
print $wohoo->ngettext("%d bird", "%d birds", $birds);
You might need to pass parameter "-k" to xgettext to make it
- extract all the strings. In above example, try with
+ extract all the strings. In above example, try with
xgettext -ktranslate -kngettext:1,2 file.php
what should create messages.po which contains two messages for
translation.
Usage with gettext.inc (standard gettext interfaces emulation)
- Check example in examples/pig_dropin.php, basically you include
- gettext.inc and use all the standard gettext interfaces as
+ Check example in examples/pig_dropin.php, basically you include
+ gettext.inc and use all the standard gettext interfaces as
documented on:
http://www.php.net/gettext
There is also simple "update" script that can be used to generate
POT file and to update the translation using msgmerge.
-Interesting TODO:
+TODO:
- o Try to parse "plural-forms" header field, and to follow C syntax
- rules. This won't be easy.
+ o Improve speed to be even more comparable to the native gettext
+ implementation.
-Boring TODO:
-
- o Learn PHP and fix bugs, slowness and other stuff resulting from
- my lack of knowledge (but *maybe*, it's not my knowledge that is
- bad, but PHP itself ;-).
-
- (This is mostly done thanks to Nico Kaiser.)
-
- o Try to use hash tables in MO files: with pre-loading, would it
+ o Try to use hash tables in MO files: with pre-loading, would it
be useful at all?
Never-asked-questions:
Well, it's quite simple. I consider that the first released thing
should be labeled "version 1" (first, right?). Zero is there to
- indicate that there's zero improvement and/or change compared to
+ indicate that there's zero improvement and/or change compared to
"version 1".
I plan to use version numbers 1.0.* for small bugfixes, and to
Mozart's 40th Symphony (there is one like that, right?).
o Can I...?
-
+
Yes, you can. This is free software (as in freedom, free speech),
and you might do whatever you wish with it, provided you do not
limit freedom of others (GPL).
+++ /dev/null
-@echo off
-xgettext -kT_ngettext:1,2 -kT_ -L PHP -o ..\..\..\locales\messages.po ..\..\..\*.php ..\..\..\services\*.php ..\..\..\templates\*.php
-if /i "%1" == "-p" goto stats
-if exist "..\..\..\locales\%1.po" goto merge
-echo "Usage: $0 [-p|<basename>]"
-goto end
-
-:stats
-msgfmt --statistics ..\..\..\locales\messages.po
-goto end
-
-:merge
-msgmerge -o ..\..\..\locales\tmp%1.po ..\..\..\locales\%1.po ..\..\..\locales\messages.po
-if exist "..\..\..\locales\%1.po" rename ..\..\..\locales\%1.po %1.po.bak
-rename ..\..\..\locales\tmp%1.po %1.po
-if exist "..\..\..\locales\%1.po.bak" del ..\..\..\locales\%1.po.bak
-msgfmt --statistics "..\..\..\locales\%1.po"
-
-:end
-echo Finished
\ No newline at end of file
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : (n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
+"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
#: pigs.php:19
msgid ""
<?php
/*
- Copyright (c) 2003,2004,2005 Danilo Segan <danilo@kvota.net>.
+ Copyright (c) 2003,2004,2005,2009 Danilo Segan <danilo@kvota.net>.
Copyright (c) 2005,2006 Steven Armstrong <sa@c-area.ch>
This file is part of PHP-gettext.
*/
+error_reporting(E_ALL | E_STRICT);
+
// define constants
-define(PROJECT_DIR, realpath('./'));
-define(LOCALE_DIR, PROJECT_DIR .'/locale');
-define(DEFAULT_LOCALE, 'en_US');
+define('PROJECT_DIR', realpath('./'));
+define('LOCALE_DIR', PROJECT_DIR .'/locale');
+define('DEFAULT_LOCALE', 'en_US');
require_once('../gettext.inc');
<?php
/*
- Copyright (c) 2003,2004,2005 Danilo Segan <danilo@kvota.net>.
+ Copyright (c) 2003,2004,2005,2009 Danilo Segan <danilo@kvota.net>.
Copyright (c) 2005,2006 Steven Armstrong <sa@c-area.ch>
This file is part of PHP-gettext.
*/
+error_reporting(E_ALL | E_STRICT);
+
// define constants
-define(PROJECT_DIR, realpath('./'));
-define(LOCALE_DIR, PROJECT_DIR .'/locale');
-define(DEFAULT_LOCALE, 'en_US');
+define('PROJECT_DIR', realpath('./'));
+define('LOCALE_DIR', PROJECT_DIR .'/locale');
+define('DEFAULT_LOCALE', 'en_US');
require_once('../gettext.inc');
#!/bin/sh
TEMPLATE=pigs.pot
-xgettext -kT_ngettext:1,2 -kT_ -L PHP -o $TEMPLATE pigs.php
-if [ x$1 == 'x-p' ]; then
+xgettext -kT_ngettext:1,2 -kT_ -L PHP -o $TEMPLATE pigs_dropin.php
+if [ "x$1" = "x-p" ]; then
msgfmt --statistics $TEMPLATE
else
if [ -f $1.po ]; then
<?php
/*
Copyright (c) 2005 Steven Armstrong <sa at c-area dot ch>
-
+ Copyright (c) 2009 Danilo Segan <danilo@kvota.net>
+
Drop in replacement for native gettext.
-
+
This file is part of PHP-gettext.
PHP-gettext is free software; you can redistribute it and/or modify
*/
/*
-LC_CTYPE 0
-LC_NUMERIC 1
-LC_TIME 2
-LC_COLLATE 3
-LC_MONETARY 4
-LC_MESSAGES 5
-LC_ALL 6
+LC_CTYPE 0
+LC_NUMERIC 1
+LC_TIME 2
+LC_COLLATE 3
+LC_MONETARY 4
+LC_MESSAGES 5
+LC_ALL 6
*/
-require(dirname(__FILE__) .'/streams.php');
-require(dirname(__FILE__) .'/gettext.php');
+
+// LC_MESSAGES is not available if php-gettext is not loaded
+// while the other constants are already available from session extension.
+if (!defined('LC_MESSAGES')) {
+ define('LC_MESSAGES', 5);
+}
+
+require('streams.php');
+require('gettext.php');
+
// Variables
$EMULATEGETTEXT = 0;
$CURRENTLOCALE = '';
+/* Class to hold a single domain included in $text_domains. */
+class domain {
+ var $l10n;
+ var $path;
+ var $codeset;
+}
// Utility functions
+/**
+ * Return a list of locales to try for any POSIX-style locale specification.
+ */
+function get_list_of_locales($locale) {
+ /* Figure out all possible locale names and start with the most
+ * specific ones. I.e. for sr_CS.UTF-8@latin, look through all of
+ * sr_CS.UTF-8@latin, sr_CS@latin, sr@latin, sr_CS.UTF-8, sr_CS, sr.
+ */
+ $locale_names = array();
+ $lang = NULL;
+ $country = NULL;
+ $charset = NULL;
+ $modifier = NULL;
+ if ($locale) {
+ if (preg_match("/^(?P<lang>[a-z]{2,3})" // language code
+ ."(?:_(?P<country>[A-Z]{2}))?" // country code
+ ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?" // charset
+ ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier
+ $locale, $matches)) {
+
+ if (isset($matches["lang"])) $lang = $matches["lang"];
+ if (isset($matches["country"])) $country = $matches["country"];
+ if (isset($matches["charset"])) $charset = $matches["charset"];
+ if (isset($matches["modifier"])) $modifier = $matches["modifier"];
+
+ if ($modifier) {
+ if ($country) {
+ if ($charset)
+ array_push($locale_names, "${lang}_$country.$charset@$modifier");
+ array_push($locale_names, "${lang}_$country@$modifier");
+ } elseif ($charset)
+ array_push($locale_names, "${lang}.$charset@$modifier");
+ array_push($locale_names, "$lang@$modifier");
+ }
+ if ($country) {
+ if ($charset)
+ array_push($locale_names, "${lang}_$country.$charset");
+ array_push($locale_names, "${lang}_$country");
+ } elseif ($charset)
+ array_push($locale_names, "${lang}.$charset");
+ array_push($locale_names, $lang);
+ }
+
+ // If the locale name doesn't match POSIX style, just include it as-is.
+ if (!in_array($locale, $locale_names))
+ array_push($locale_names, $locale);
+ }
+ return $locale_names;
+}
+
/**
* Utility function to get a StreamReader for the given text domain.
*/
function _get_reader($domain=null, $category=5, $enable_cache=true) {
- global $text_domains, $default_domain, $LC_CATEGORIES;
- if (!isset($domain)) $domain = $default_domain;
- if (!isset($text_domains[$domain]->l10n)) {
- // get the current locale
- $locale = _setlocale(LC_MESSAGES, 0);
- $p = isset($text_domains[$domain]->path) ? $text_domains[$domain]->path : './';
- $path = $p . "$locale/". $LC_CATEGORIES[$category] ."/$domain.mo";
- if (file_exists($path)) {
- $input = new FileReader($path);
- }
- else {
- $input = null;
- }
- $text_domains[$domain]->l10n = new gettext_reader($input, $enable_cache);
- }
- return $text_domains[$domain]->l10n;
+ global $text_domains, $default_domain, $LC_CATEGORIES;
+ if (!isset($domain)) $domain = $default_domain;
+ if (!isset($text_domains[$domain]->l10n)) {
+ // get the current locale
+ $locale = _setlocale(LC_MESSAGES, 0);
+ $bound_path = isset($text_domains[$domain]->path) ?
+ $text_domains[$domain]->path : './';
+ $subpath = $LC_CATEGORIES[$category] ."/$domain.mo";
+
+ $locale_names = get_list_of_locales($locale);
+ $input = null;
+ foreach ($locale_names as $locale) {
+ $full_path = $bound_path . $locale . "/" . $subpath;
+ if (file_exists($full_path)) {
+ $input = new FileReader($full_path);
+ break;
+ }
+ }
+
+ if (!array_key_exists($domain, $text_domains)) {
+ // Initialize an empty domain object.
+ $text_domains[$domain] = new domain();
+ }
+ $text_domains[$domain]->l10n = new gettext_reader($input,
+ $enable_cache);
+ }
+ return $text_domains[$domain]->l10n;
}
/**
/**
* Checks if the current locale is supported on this system.
*/
-function _check_locale() {
+function _check_locale_and_function($function=false) {
global $EMULATEGETTEXT;
+ if ($function and !function_exists($function))
+ return false;
return !$EMULATEGETTEXT;
}
* Get the codeset for the given domain.
*/
function _get_codeset($domain=null) {
- global $text_domains, $default_domain, $LC_CATEGORIES;
- if (!isset($domain)) $domain = $default_domain;
- return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding');
+ global $text_domains, $default_domain, $LC_CATEGORIES;
+ if (!isset($domain)) $domain = $default_domain;
+ return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding');
}
/**
* Convert the given string to the encoding set by bind_textdomain_codeset.
*/
function _encode($text) {
- $source_encoding = mb_detect_encoding($text);
- $target_encoding = _get_codeset();
- if ($source_encoding != $target_encoding) {
- return mb_convert_encoding($text, $target_encoding, $source_encoding);
- }
- else {
- return $text;
- }
+ $source_encoding = mb_detect_encoding($text);
+ $target_encoding = _get_codeset();
+ if ($source_encoding != $target_encoding) {
+ return mb_convert_encoding($text, $target_encoding, $source_encoding);
+ }
+ else {
+ return $text;
+ }
}
-
-
// Custom implementation of the standard gettext related functions
+/**
+ * Returns passed in $locale, or environment variable $LANG if $locale == ''.
+ */
+function _get_default_locale($locale) {
+ if ($locale == '') // emulate variable support
+ return getenv('LANG');
+ else
+ return $locale;
+}
+
/**
* Sets a requested locale, if needed emulates it.
*/
function _setlocale($category, $locale) {
global $CURRENTLOCALE, $EMULATEGETTEXT;
if ($locale === 0) { // use === to differentiate between string "0"
- if ($CURRENTLOCALE != '')
+ if ($CURRENTLOCALE != '')
return $CURRENTLOCALE;
- else
+ else
// obey LANG variable, maybe extend to support all of LC_* vars
// even if we tried to read locale without setting it first
return _setlocale($category, $CURRENTLOCALE);
} else {
- $ret = 0;
- if (function_exists('setlocale')) // I don't know if this ever happens ;)
- $ret = setlocale($category, $locale);
- if (($ret and $locale == '') or ($ret == $locale)) {
- $EMULATEGETTEXT = 0;
+ if (function_exists('setlocale')) {
+ $ret = setlocale($category, $locale);
+ if (($locale == '' and !$ret) or // failed setting it by env
+ ($locale != '' and $ret != $locale)) { // failed setting it
+ // Failed setting it according to environment.
+ $CURRENTLOCALE = _get_default_locale($locale);
+ $EMULATEGETTEXT = 1;
+ } else {
$CURRENTLOCALE = $ret;
+ $EMULATEGETTEXT = 0;
+ }
} else {
- if ($locale == '') // emulate variable support
- $CURRENTLOCALE = getenv('LANG');
- else
- $CURRENTLOCALE = $locale;
- $EMULATEGETTEXT = 1;
+ // No function setlocale(), emulate it all.
+ $CURRENTLOCALE = _get_default_locale($locale);
+ $EMULATEGETTEXT = 1;
}
+ // Allow locale to be changed on the go for one translation domain.
+ global $text_domains, $default_domain;
+ unset($text_domains[$default_domain]->l10n);
return $CURRENTLOCALE;
}
}
* Sets the path for a domain.
*/
function _bindtextdomain($domain, $path) {
- global $text_domains;
- // ensure $path ends with a slash
- if ($path[strlen($path) - 1] != '/') $path .= '/';
- elseif ($path[strlen($path) - 1] != '\\') $path .= '\\';
- $text_domains[$domain]->path = $path;
+ global $text_domains;
+ // ensure $path ends with a slash ('/' should work for both, but lets still play nice)
+ if (substr(php_uname(), 0, 7) == "Windows") {
+ if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/')
+ $path .= '\\';
+ } else {
+ if ($path[strlen($path)-1] != '/')
+ $path .= '/';
+ }
+ if (!array_key_exists($domain, $text_domains)) {
+ // Initialize an empty domain object.
+ $text_domains[$domain] = new domain();
+ }
+ $text_domains[$domain]->path = $path;
}
/**
* Specify the character encoding in which the messages from the DOMAIN message catalog will be returned.
*/
function _bind_textdomain_codeset($domain, $codeset) {
- global $text_domains;
- $text_domains[$domain]->codeset = $codeset;
+ global $text_domains;
+ $text_domains[$domain]->codeset = $codeset;
}
/**
* Sets the default domain.
*/
function _textdomain($domain) {
- global $default_domain;
- $default_domain = $domain;
+ global $default_domain;
+ $default_domain = $domain;
}
/**
* Lookup a message in the current domain.
*/
function _gettext($msgid) {
- $l10n = _get_reader();
- //return $l10n->translate($msgid);
- return _encode($l10n->translate($msgid));
+ $l10n = _get_reader();
+ return _encode($l10n->translate($msgid));
}
+
/**
* Alias for gettext.
*/
function __($msgid) {
- return _gettext($msgid);
+ return _gettext($msgid);
}
+
/**
* Plural version of gettext.
*/
function _ngettext($single, $plural, $number) {
- $l10n = _get_reader();
- //return $l10n->ngettext($single, $plural, $number);
- return _encode($l10n->ngettext($single, $plural, $number));
+ $l10n = _get_reader();
+ return _encode($l10n->ngettext($single, $plural, $number));
}
/**
* Override the current domain.
*/
function _dgettext($domain, $msgid) {
- $l10n = _get_reader($domain);
- //return $l10n->translate($msgid);
- return _encode($l10n->translate($msgid));
+ $l10n = _get_reader($domain);
+ return _encode($l10n->translate($msgid));
}
+
/**
* Plural version of dgettext.
*/
function _dngettext($domain, $single, $plural, $number) {
- $l10n = _get_reader($domain);
- //return $l10n->ngettext($single, $plural, $number);
- return _encode($l10n->ngettext($single, $plural, $number));
+ $l10n = _get_reader($domain);
+ return _encode($l10n->ngettext($single, $plural, $number));
}
/**
* Overrides the domain and category for a single lookup.
*/
function _dcgettext($domain, $msgid, $category) {
- $l10n = _get_reader($domain, $category);
- //return $l10n->translate($msgid);
- return _encode($l10n->translate($msgid));
+ $l10n = _get_reader($domain, $category);
+ return _encode($l10n->translate($msgid));
}
/**
* Plural version of dcgettext.
*/
function _dcngettext($domain, $single, $plural, $number, $category) {
- $l10n = _get_reader($domain, $category);
- //return $l10n->ngettext($single, $plural, $number);
- return _encode($l10n->ngettext($single, $plural, $number));
+ $l10n = _get_reader($domain, $category);
+ return _encode($l10n->ngettext($single, $plural, $number));
}
+/**
+ * Context version of gettext.
+ */
+function _pgettext($context, $msgid) {
+ $l10n = _get_reader();
+ return _encode($l10n->pgettext($context, $msgid));
+}
+/**
+ * Override the current domain in a context gettext call.
+ */
+function _dpgettext($domain, $context, $msgid) {
+ $l10n = _get_reader($domain);
+ return _encode($l10n->pgettext($context, $msgid));
+}
-// Wrappers to use if the standard gettext functions are available, but the current locale is not supported by the system.
-// Use the standard impl if the current locale is supported, use the custom impl otherwise.
+/**
+ * Overrides the domain and category for a single context-based lookup.
+ */
+function _dcpgettext($domain, $context, $msgid, $category) {
+ $l10n = _get_reader($domain, $category);
+ return _encode($l10n->pgettext($context, $msgid));
+}
+
+/**
+ * Context version of ngettext.
+ */
+function _npgettext($context, $singular, $plural) {
+ $l10n = _get_reader();
+ return _encode($l10n->npgettext($context, $singular, $plural));
+}
+
+/**
+ * Override the current domain in a context ngettext call.
+ */
+function _dnpgettext($domain, $context, $singular, $plural) {
+ $l10n = _get_reader($domain);
+ return _encode($l10n->npgettext($context, $singular, $plural));
+}
+
+/**
+ * Overrides the domain and category for a plural context-based lookup.
+ */
+function _dcnpgettext($domain, $context, $singular, $plural, $category) {
+ $l10n = _get_reader($domain, $category);
+ return _encode($l10n->npgettext($context, $singular, $plural));
+}
+
+
+
+// Wrappers to use if the standard gettext functions are available,
+// but the current locale is not supported by the system.
+// Use the standard impl if the current locale is supported, use the
+// custom impl otherwise.
function T_setlocale($category, $locale) {
return _setlocale($category, $locale);
}
function T_bindtextdomain($domain, $path) {
- if (_check_locale()) return bindtextdomain($domain, $path);
- else return _bindtextdomain($domain, $path);
+ if (_check_locale_and_function()) return bindtextdomain($domain, $path);
+ else return _bindtextdomain($domain, $path);
}
function T_bind_textdomain_codeset($domain, $codeset) {
// bind_textdomain_codeset is available only in PHP 4.2.0+
- if (_check_locale() and function_exists('bind_textdomain_codeset')) return bind_textdomain_codeset($domain, $codeset);
- else return _bind_textdomain_codeset($domain, $codeset);
+ if (_check_locale_and_function('bind_textdomain_codeset'))
+ return bind_textdomain_codeset($domain, $codeset);
+ else return _bind_textdomain_codeset($domain, $codeset);
}
function T_textdomain($domain) {
- if (_check_locale()) return textdomain($domain);
- else return _textdomain($domain);
+ if (_check_locale_and_function()) return textdomain($domain);
+ else return _textdomain($domain);
}
function T_gettext($msgid) {
- if (_check_locale()) return gettext($msgid);
- else return _gettext($msgid);
+ if (_check_locale_and_function()) return gettext($msgid);
+ else return _gettext($msgid);
}
function T_($msgid) {
- if (_check_locale()) return _($msgid);
- return __($msgid);
+ if (_check_locale_and_function()) return _($msgid);
+ return __($msgid);
}
function T_ngettext($single, $plural, $number) {
- if (_check_locale()) return ngettext($single, $plural, $number);
- else return _ngettext($single, $plural, $number);
+ if (_check_locale_and_function())
+ return ngettext($single, $plural, $number);
+ else return _ngettext($single, $plural, $number);
}
function T_dgettext($domain, $msgid) {
- if (_check_locale()) return dgettext($domain, $msgid);
- else return _dgettext($domain, $msgid);
+ if (_check_locale_and_function()) return dgettext($domain, $msgid);
+ else return _dgettext($domain, $msgid);
}
function T_dngettext($domain, $single, $plural, $number) {
- if (_check_locale()) return dngettext($domain, $single, $plural, $number);
- else return _dngettext($domain, $single, $plural, $number);
+ if (_check_locale_and_function())
+ return dngettext($domain, $single, $plural, $number);
+ else return _dngettext($domain, $single, $plural, $number);
}
function T_dcgettext($domain, $msgid, $category) {
- if (_check_locale()) return dcgettext($domain, $msgid, $category);
- else return _dcgettext($domain, $msgid, $category);
+ if (_check_locale_and_function())
+ return dcgettext($domain, $msgid, $category);
+ else return _dcgettext($domain, $msgid, $category);
}
function T_dcngettext($domain, $single, $plural, $number, $category) {
- if (_check_locale()) return dcngettext($domain, $single, $plural, $number, $category);
- else return _dcngettext($domain, $single, $plural, $number, $category);
+ if (_check_locale_and_function())
+ return dcngettext($domain, $single, $plural, $number, $category);
+ else return _dcngettext($domain, $single, $plural, $number, $category);
+}
+
+function T_pgettext($context, $msgid) {
+ if (_check_locale_and_function('pgettext'))
+ return pgettext($context, $msgid);
+ else
+ return _pgettext($context, $msgid);
+}
+
+function T_dpgettext($domain, $context, $msgid) {
+ if (_check_locale_and_function('dpgettext'))
+ return dpgettext($domain, $context, $msgid);
+ else
+ return _dpgettext($domain, $context, $msgid);
+}
+
+function T_dcpgettext($domain, $context, $msgid, $category) {
+ if (_check_locale_and_function('dcpgettext'))
+ return dcpgettext($domain, $context, $msgid, $category);
+ else
+ return _dcpgettext($domain, $context, $msgid, $category);
+}
+
+function T_npgettext($context, $singular, $plural) {
+ if (_check_locale_and_function('npgettext'))
+ return npgettext($context, $single, $plural, $number);
+ else
+ return _npgettext($context, $single, $plural, $number);
+}
+
+function T_dnpgettext($domain, $context, $singular, $plural) {
+ if (_check_locale_and_function('dnpgettext'))
+ return dnpgettext($domain, $context, $single, $plural, $number);
+ else
+ return _dnpgettext($domain, $context, $single, $plural, $number);
+}
+
+function T_dcnpgettext($domain, $context, $singular, $plural, $category) {
+ if (_check_locale_and_function('dcnpgettext'))
+ return dcnpgettext($domain, $context, $single,
+ $plural, $number, $category);
+ else
+ return _dcnpgettext($domain, $context, $single,
+ $plural, $number, $category);
}
// Wrappers used as a drop in replacement for the standard gettext functions
if (!function_exists('gettext')) {
- function bindtextdomain($domain, $path) {
- return _bindtextdomain($domain, $path);
- }
- function bind_textdomain_codeset($domain, $codeset) {
- return _bind_textdomain_codeset($domain, $codeset);
- }
- function textdomain($domain) {
- return _textdomain($domain);
- }
- function gettext($msgid) {
- return _gettext($msgid);
- }
- function _($msgid) {
- return __($msgid);
- }
- function ngettext($single, $plural, $number) {
- return _ngettext($single, $plural, $number);
- }
- function dgettext($domain, $msgid) {
- return _dgettext($domain, $msgid);
- }
- function dngettext($domain, $single, $plural, $number) {
- return _dngettext($domain, $single, $plural, $number);
- }
- function dcgettext($domain, $msgid, $category) {
- return _dcgettext($domain, $msgid, $category);
- }
- function dcngettext($domain, $single, $plural, $number, $category) {
- return _dcngettext($domain, $single, $plural, $number, $category);
- }
-}
-
-?>
\ No newline at end of file
+ function bindtextdomain($domain, $path) {
+ return _bindtextdomain($domain, $path);
+ }
+ function bind_textdomain_codeset($domain, $codeset) {
+ return _bind_textdomain_codeset($domain, $codeset);
+ }
+ function textdomain($domain) {
+ return _textdomain($domain);
+ }
+ function gettext($msgid) {
+ return _gettext($msgid);
+ }
+ function _($msgid) {
+ return __($msgid);
+ }
+ function ngettext($single, $plural, $number) {
+ return _ngettext($single, $plural, $number);
+ }
+ function dgettext($domain, $msgid) {
+ return _dgettext($domain, $msgid);
+ }
+ function dngettext($domain, $single, $plural, $number) {
+ return _dngettext($domain, $single, $plural, $number);
+ }
+ function dcgettext($domain, $msgid, $category) {
+ return _dcgettext($domain, $msgid, $category);
+ }
+ function dcngettext($domain, $single, $plural, $number, $category) {
+ return _dcngettext($domain, $single, $plural, $number, $category);
+ }
+ function pgettext($context, $msgid) {
+ return _pgettext($context, $msgid);
+ }
+ function npgettext($context, $single, $plural, $number) {
+ return _npgettext($context, $single, $plural, $number);
+ }
+ function dpgettext($domain, $context, $msgid) {
+ return _dpgettext($domain, $context, $msgid);
+ }
+ function dnpgettext($domain, $context, $single, $plural, $number) {
+ return _dnpgettext($domain, $context, $single, $plural, $number);
+ }
+ function dcpgettext($domain, $context, $msgid, $category) {
+ return _dcpgettext($domain, $context, $msgid, $category);
+ }
+ function dcnpgettext($domain, $context, $single, $plural,
+ $number, $category) {
+ return _dcnpgettext($domain, $context, $single, $plural,
+ $number, $category);
+ }
+}
+
+?>
<?php
/*
- Copyright (c) 2003 Danilo Segan <danilo@kvota.net>.
+ Copyright (c) 2003, 2009 Danilo Segan <danilo@kvota.net>.
Copyright (c) 2005 Nico Kaiser <nico@siriux.net>
-
+
This file is part of PHP-gettext.
PHP-gettext is free software; you can redistribute it and/or modify
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+
/**
* Provides a simple gettext replacement that works independently from
* the system's gettext abilities.
* It can read MO files and use them for translating strings.
* The files are passed to gettext_reader as a Stream (see streams.php)
- *
+ *
* This version has the ability to cache all strings and translations to
* speed up the string lookup.
* While the cache is enabled by default, it can be switched off with the
class gettext_reader {
//public:
var $error = 0; // public variable that holds error code (0 if no error)
-
+
//private:
var $BYTEORDER = 0; // 0: low endian, 1: big endian
var $STREAM = NULL;
/* Methods */
-
-
+
+
/**
* Reads a 32bit Integer from the Stream
- *
+ *
* @access private
* @return Integer from the Stream
*/
function readint() {
if ($this->BYTEORDER == 0) {
// low endian
- return array_shift(unpack('V', $this->STREAM->read(4)));
+ $input=unpack('V', $this->STREAM->read(4));
+ return array_shift($input);
} else {
// big endian
- return array_shift(unpack('N', $this->STREAM->read(4)));
+ $input=unpack('N', $this->STREAM->read(4));
+ return array_shift($input);
}
}
+ function read($bytes) {
+ return $this->STREAM->read($bytes);
+ }
+
/**
* Reads an array of Integers from the Stream
- *
+ *
* @param int count How many elements should be read
* @return Array of Integers
*/
return unpack('N'.$count, $this->STREAM->read(4 * $count));
}
}
-
+
/**
* Constructor
- *
+ *
* @param object Reader the StreamReader object
* @param boolean enable_cache Enable or disable caching of strings (default on)
*/
$this->short_circuit = true;
return;
}
-
+
// Caching can be turned off
$this->enable_cache = $enable_cache;
- // $MAGIC1 = (int)0x950412de; //bug in PHP 5
- $MAGIC1 = (int) - 1794895138;
- // $MAGIC2 = (int)0xde120495; //bug
- $MAGIC2 = (int) - 569244523;
+ $MAGIC1 = "\x95\x04\x12\xde";
+ $MAGIC2 = "\xde\x12\x04\x95";
$this->STREAM = $Reader;
- $magic = $this->readint();
+ $magic = $this->read(4);
if ($magic == $MAGIC1) {
- $this->BYTEORDER = 0;
- } elseif ($magic == $MAGIC2) {
$this->BYTEORDER = 1;
+ } elseif ($magic == $MAGIC2) {
+ $this->BYTEORDER = 0;
} else {
$this->error = 1; // not MO file
return false;
}
-
+
// FIXME: Do we care about revision? We should.
$revision = $this->readint();
-
+
$this->total = $this->readint();
$this->originals = $this->readint();
$this->translations = $this->readint();
}
-
+
/**
* Loads the translation tables from the MO file into the cache
* If caching is enabled, also loads all strings into a cache
* to speed up translation lookups
- *
+ *
* @access private
*/
function load_tables() {
is_array($this->table_originals) &&
is_array($this->table_translations))
return;
-
+
/* get original and translations tables */
- $this->STREAM->seekto($this->originals);
- $this->table_originals = $this->readintarray($this->total * 2);
- $this->STREAM->seekto($this->translations);
- $this->table_translations = $this->readintarray($this->total * 2);
-
+ if (!is_array($this->table_originals)) {
+ $this->STREAM->seekto($this->originals);
+ $this->table_originals = $this->readintarray($this->total * 2);
+ }
+ if (!is_array($this->table_translations)) {
+ $this->STREAM->seekto($this->translations);
+ $this->table_translations = $this->readintarray($this->total * 2);
+ }
+
if ($this->enable_cache) {
$this->cache_translations = array ();
/* read all strings in the cache */
}
}
}
-
+
/**
* Returns a string from the "originals" table
- *
+ *
* @access private
* @param int num Offset number of original string
* @return string Requested string if found, otherwise ''
$data = $this->STREAM->read($length);
return (string)$data;
}
-
+
/**
* Returns a string from the "translations" table
- *
+ *
* @access private
* @param int num Offset number of original string
* @return string Requested string if found, otherwise ''
$data = $this->STREAM->read($length);
return (string)$data;
}
-
+
/**
* Binary search for string
- *
+ *
* @access private
* @param string string
* @param int start (internally used in recursive function)
return $this->find_string($string, $half, $end);
}
}
-
+
/**
* Translates a string
- *
+ *
* @access public
* @param string string to be translated
* @return string translated string (or original, if not found)
function translate($string) {
if ($this->short_circuit)
return $string;
- $this->load_tables();
-
+ $this->load_tables();
+
if ($this->enable_cache) {
// Caching enabled, get translated string from cache
if (array_key_exists($string, $this->cache_translations))
}
}
+ /**
+ * Sanitize plural form expression for use in PHP eval call.
+ *
+ * @access private
+ * @return string sanitized plural form expression
+ */
+ function sanitize_plural_expression($expr) {
+ // Get rid of disallowed characters.
+ $expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr);
+
+ // Add parenthesis for tertiary '?' operator.
+ $expr .= ';';
+ $res = '';
+ $p = 0;
+ for ($i = 0; $i < strlen($expr); $i++) {
+ $ch = $expr[$i];
+ switch ($ch) {
+ case '?':
+ $res .= ' ? (';
+ $p++;
+ break;
+ case ':':
+ $res .= ') : (';
+ break;
+ case ';':
+ $res .= str_repeat( ')', $p) . ';';
+ $p = 0;
+ break;
+ default:
+ $res .= $ch;
+ }
+ }
+ return $res;
+ }
+
+ /**
+ * Parse full PO header and extract only plural forms line.
+ *
+ * @access private
+ * @return string verbatim plural form header field
+ */
+ function extract_plural_forms_header_from_po_header($header) {
+ if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs))
+ $expr = $regs[2];
+ else
+ $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
+ return $expr;
+ }
+
/**
* Get possible plural forms from MO header
- *
+ *
* @access private
* @return string plural form header
*/
function get_plural_forms() {
- // lets assume message number 0 is header
+ // lets assume message number 0 is header
// this is true, right?
$this->load_tables();
-
+
// cache header field for plural forms
if (! is_string($this->pluralheader)) {
if ($this->enable_cache) {
} else {
$header = $this->get_translation_string(0);
}
- if (eregi("plural-forms: ([^\n]*)\n", $header, $regs))
- $expr = $regs[1];
- else
- $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
- $this->pluralheader = $expr;
+ $expr = $this->extract_plural_forms_header_from_po_header($header);
+ $this->pluralheader = $this->sanitize_plural_expression($expr);
}
return $this->pluralheader;
}
/**
* Detects which plural form to take
- *
+ *
* @access private
* @param n count
* @return int array index of the right plural form
$string = str_replace('nplurals',"\$total",$string);
$string = str_replace("n",$n,$string);
$string = str_replace('plural',"\$plural",$string);
-
+
$total = 0;
$plural = 0;
/**
* Plural version of gettext
- *
+ *
* @access public
* @param string single
* @param string plural
}
// find out the appropriate form
- $select = $this->select_string($number);
-
+ $select = $this->select_string($number);
+
// this should contains all strings separated by NULLs
- $key = $single.chr(0).$plural;
-
-
+ $key = $single . chr(0) . $plural;
+
+
if ($this->enable_cache) {
if (! array_key_exists($key, $this->cache_translations)) {
return ($number != 1) ? $plural : $single;
}
}
+ function pgettext($context, $msgid) {
+ $key = $context . chr(4) . $msgid;
+ return $this->translate($key);
+ }
+
+ function npgettext($context, $singular, $plural, $number) {
+ $singular = $context . chr(4) . $singular;
+ return $this->ngettext($singular, $plural, $number);
+ }
}
?>
<?php
/*
- Copyright (c) 2003, 2005 Danilo Segan <danilo@kvota.net>.
+ Copyright (c) 2003, 2005, 2006, 2009 Danilo Segan <danilo@kvota.net>.
This file is part of PHP-gettext.
*/
-// Simple class to wrap file streams, string streams, etc.
-// seek is essential, and it should be byte stream
+ // Simple class to wrap file streams, string streams, etc.
+ // seek is essential, and it should be byte stream
class StreamReader {
// should return a string [FIXME: perhaps return array of bytes?]
function read($bytes) {
return false;
}
-
+
// should return new position
function seekto($position) {
return false;
}
-
+
// returns current position
function currentpos() {
return false;
}
-
+
// returns length of entire stream (limit for seekto()s)
function length() {
return false;
}
-}
+};
class StringReader {
var $_pos;
return strlen($this->_str);
}
-}
+};
class FileReader {
$this->_pos = 0;
$this->_fd = fopen($filename,'rb');
if (!$this->_fd) {
- $this->error = 3; // Cannot read file, probably permissions
- return false;
+ $this->error = 3; // Cannot read file, probably permissions
+ return false;
}
} else {
$this->error = 2; // File doesn't exist
// PHP 5.1.1 does not read more than 8192 bytes in one fread()
// the discussions at PHP Bugs suggest it's the intended behaviour
+ $data = '';
while ($bytes > 0) {
$chunk = fread($this->_fd, $bytes);
$data .= $chunk;
$bytes -= strlen($chunk);
}
$this->_pos = ftell($this->_fd);
-
+
return $data;
} else return '';
}
fclose($this->_fd);
}
-}
+};
-// Preloads entire file in memory first, then creates a StringReader
+// Preloads entire file in memory first, then creates a StringReader
// over it (it assumes knowledge of StringReader internals)
class CachedFileReader extends StringReader {
function CachedFileReader($filename) {
$fd = fopen($filename,'rb');
if (!$fd) {
- $this->error = 3; // Cannot read file, probably permissions
- return false;
+ $this->error = 3; // Cannot read file, probably permissions
+ return false;
}
$this->_str = fread($fd, $length);
fclose($fd);
return false;
}
}
-}
+};
-?>
\ No newline at end of file
+?>
--- /dev/null
+<?php
+require_once('PHPUnit/Framework.php');
+require_once('gettext.inc');
+
+class LocaleTest extends PHPUnit_Framework_TestCase
+{
+ public function test_setlocale()
+ {
+ // _setlocale defaults to a locale name from environment variable LANG.
+ putenv("LANG=sr_RS");
+ $this->assertEquals('sr_RS', _setlocale(LC_MESSAGES, 0));
+
+ // For an existing locale, it never needs emulation.
+ putenv("LANG=C");
+ _setlocale(LC_MESSAGES, "");
+ $this->assertEquals(0, locale_emulation());
+
+ // If we set it to a non-existent locale, it still works, but uses
+ // emulation.
+ _setlocale(LC_MESSAGES, "xxx_XXX");
+ $this->assertEquals('xxx_XXX', _setlocale(LC_MESSAGES, 0));
+ $this->assertEquals(1, locale_emulation());
+ }
+
+ public function test_get_list_of_locales()
+ {
+ // For a locale containing country code, we prefer
+ // full locale name, but if that's not found, fall back
+ // to the language only locale name.
+ $this->assertEquals(array("sr_RS", "sr"),
+ get_list_of_locales("sr_RS"));
+
+ // If language code is used, it's the only thing returned.
+ $this->assertEquals(array("sr"),
+ get_list_of_locales("sr"));
+
+ // There is support for language and charset only.
+ $this->assertEquals(array("sr.UTF-8", "sr"),
+ get_list_of_locales("sr.UTF-8"));
+
+ // It can also split out character set from the full locale name.
+ $this->assertEquals(array("sr_RS.UTF-8", "sr_RS", "sr"),
+ get_list_of_locales("sr_RS.UTF-8"));
+
+ // There is support for @modifier in locale names as well.
+ $this->assertEquals(array("sr_RS.UTF-8@latin", "sr_RS@latin", "sr@latin",
+ "sr_RS.UTF-8", "sr_RS", "sr"),
+ get_list_of_locales("sr_RS.UTF-8@latin"));
+
+ // We can pass in only language and modifier.
+ $this->assertEquals(array("sr@latin", "sr"),
+ get_list_of_locales("sr@latin"));
+
+
+ // If locale name is not following the regular POSIX pattern,
+ // it's used verbatim.
+ $this->assertEquals(array("something"),
+ get_list_of_locales("something"));
+
+ // Passing in an empty string returns an empty array.
+ $this->assertEquals(array(),
+ get_list_of_locales(""));
+ }
+}
+
+?>
--- /dev/null
+<?php
+require_once('PHPUnit/Framework.php');
+//require_once('gettext.php');
+
+class ParsingTest extends PHPUnit_Framework_TestCase
+{
+ public function test_extract_plural_forms_header_from_po_header()
+ {
+ $parser = new gettext_reader(NULL);
+ // It defaults to a "Western-style" plural header.
+ $this->assertEquals(
+ 'nplurals=2; plural=n == 1 ? 0 : 1;',
+ $parser->extract_plural_forms_header_from_po_header(""));
+
+ // Extracting it from the middle of the header works.
+ $this->assertEquals(
+ 'nplurals=1; plural=0;',
+ $parser->extract_plural_forms_header_from_po_header(
+ "Content-type: text/html; charset=UTF-8\n"
+ ."Plural-Forms: nplurals=1; plural=0;\n"
+ ."Last-Translator: nobody\n"
+ ));
+
+ // It's also case-insensitive.
+ $this->assertEquals(
+ 'nplurals=1; plural=0;',
+ $parser->extract_plural_forms_header_from_po_header(
+ "PLURAL-forms: nplurals=1; plural=0;\n"
+ ));
+
+ // It falls back to default if it's not on a separate line.
+ $this->assertEquals(
+ 'nplurals=2; plural=n == 1 ? 0 : 1;',
+ $parser->extract_plural_forms_header_from_po_header(
+ "Content-type: text/html; charset=UTF-8" // note the missing \n here
+ ."Plural-Forms: nplurals=1; plural=0;\n"
+ ."Last-Translator: nobody\n"
+ ));
+
+ }
+
+}
+?>
+++ /dev/null
-<?php
-/**
- * UTF8 helper functions
- *
- * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-
-/**
- * URL-Encode a filename to allow unicodecharacters
- *
- * Slashes are not encoded
- *
- * When the second parameter is true the string will
- * be encoded only if non ASCII characters are detected -
- * This makes it safe to run it multiple times on the
- * same string (default is true)
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @see urlencode
- */
-function utf8_encodeFN($file,$safe=true){
- if($safe && preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){
- return $file;
- }
- $file = urlencode($file);
- $file = str_replace('%2F','/',$file);
- return $file;
-}
-
-/**
- * URL-Decode a filename
- *
- * This is just a wrapper around urldecode
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @see urldecode
- */
-function utf8_decodeFN($file){
- $file = urldecode($file);
- return $file;
-}
-
-/**
- * Checks if a string contains 7bit ASCII only
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-function utf8_isASCII($str){
- for($i=0; $i<strlen($str); $i++){
- if(ord($str{$i}) >127) return false;
- }
- return true;
-}
-
-/**
- * Tries to detect if a string is in Unicode encoding
- *
- * @author <bmorel@ssi.fr>
- * @link http://www.php.net/manual/en/function.utf8-encode.php
- */
-function utf8_check($Str) {
- for ($i=0; $i<strlen($Str); $i++) {
- if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb
- elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
- elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
- elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
- elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
- elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
- else return false; # Does not match any model
- for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
- if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80))
- return false;
- }
- }
- return true;
-}
-
-/**
- * This is a unicode aware replacement for strlen()
- *
- * Uses mb_string extension if available
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @see strlen()
- */
-function utf8_strlen($string){
- if(!defined('UTF8_NOMBSTRING') && function_exists('mb_strlen'))
- return mb_strlen($string,'utf-8');
-
- $uni = utf8_to_unicode($string);
- return count($uni);
-}
-
-/**
- * This is a unicode aware replacement for substr()
- *
- * Uses mb_string extension if available
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @see substr()
- */
-function utf8_substr($str, $start, $length=null){
- if(!defined('UTF8_NOMBSTRING') && function_exists('mb_substr'))
- return mb_substr($str,$start,$length,'utf-8');
-
- $uni = utf8_to_unicode($str);
- return unicode_to_utf8(array_slice($uni,$start,$length));
-}
-
-/**
- * This is a unicode aware replacement for strtolower()
- *
- * Uses mb_string extension if available
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @see strtolower()
- * @see utf8_strtoupper()
- */
-function utf8_strtolower($string){
- if(!defined('UTF8_NOMBSTRING') && function_exists('mb_strtolower'))
- return mb_strtolower($string,'utf-8');
-
- global $UTF8_UPPER_TO_LOWER;
- $uni = utf8_to_unicode($string);
- for ($i=0; $i < count($uni); $i++){
- if($UTF8_UPPER_TO_LOWER[$uni[$i]]){
- $uni[$i] = $UTF8_UPPER_TO_LOWER[$uni[$i]];
- }
- }
- return unicode_to_utf8($uni);
-}
-
-/**
- * This is a unicode aware replacement for strtoupper()
- *
- * Uses mb_string extension if available
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @see strtoupper()
- * @see utf8_strtoupper()
- */
-function utf8_strtoupper($string){
- if(!defined('UTF8_NOMBSTRING') && function_exists('mb_strtolower'))
- return mb_strtolower($string,'utf-8');
-
- global $UTF8_LOWER_TO_UPPER;
- $uni = utf8_to_unicode($string);
- for ($i=0; $i < count($uni); $i++){
- if($UTF8_LOWER_TO_UPPER[$uni[$i]]){
- $uni[$i] = $UTF8_LOWER_TO_UPPER[$uni[$i]];
- }
- }
- return unicode_to_utf8($uni);
-}
-
-/**
- * Replace accented UTF-8 characters by unaccented ASCII-7 equivalents
- *
- * Use the optional parameter to just deaccent lower ($case = -1) or upper ($case = 1)
- * letters. Default is to deaccent both cases ($case = 0)
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-function utf8_deaccent($string,$case=0){
- if($case <= 0){
- global $UTF8_LOWER_ACCENTS;
- $string = str_replace(array_keys($UTF8_LOWER_ACCENTS),array_values($UTF8_LOWER_ACCENTS),$string);
- }
- if($case >= 0){
- global $UTF8_UPPER_ACCENTS;
- $string = str_replace(array_keys($UTF8_UPPER_ACCENTS),array_values($UTF8_UPPER_ACCENTS),$string);
- }
- return $string;
-}
-
-/**
- * Removes special characters (nonalphanumeric) from a UTF-8 string
- *
- * Be sure to specify all specialchars you give in $repl in $keep, too
- * or it won't work.
- *
- * This function adds the controlchars 0x00 to 0x19 to the array of
- * stripped chars (they are not included in $UTF8_SPECIAL_CHARS)
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @param string $string The UTF8 string to strip of special chars
- * @param string $repl Replace special with this string
- * @param string $keep Special chars to keep (in UTF8)
- */
-function utf8_stripspecials($string,$repl='',$keep=''){
- global $UTF8_SPECIAL_CHARS;
- if($keep != ''){
- $specials = array_diff($UTF8_SPECIAL_CHARS, utf8_to_unicode($keep));
- }else{
- $specials = $UTF8_SPECIAL_CHARS;
- }
-
- $specials = unicode_to_utf8($specials);
- $specials = preg_quote($specials, '/');
-
- return preg_replace('/[\x00-\x19'.$specials.']/u',$repl,$string);
-}
-
-/**
- * This is an Unicode aware replacement for strpos
- *
- * Uses mb_string extension if available
- *
- * @author Scott Michael Reynen <scott@randomchaos.com>
- * @author Andreas Gohr <andi@splitbrain.org>
- * @link http://www.randomchaos.com/document.php?source=php_and_unicode
- * @see strpos()
- */
-function utf8_strpos($haystack, $needle,$offset=0) {
- if(!defined('UTF8_NOMBSTRING') && function_exists('mb_strpos'))
- return mb_strpos($haystack,$needle,$offset,'utf-8');
-
- $haystack = utf8_to_unicode($haystack);
- $needle = utf8_to_unicode($needle);
- $position = $offset;
- $found = false;
-
- while( (! $found ) && ( $position < count( $haystack ) ) ) {
- if ( $needle[0] == $haystack[$position] ) {
- for ($i = 1; $i < count( $needle ); $i++ ) {
- if ( $needle[$i] != $haystack[ $position + $i ] ) break;
- }
- if ( $i == count( $needle ) ) {
- $found = true;
- $position--;
- }
- }
- $position++;
- }
- return ( $found == true ) ? $position : false;
-}
-
-/**
- * This function will any UTF-8 encoded text and return it as
- * a list of Unicode values:
- *
- * @author Scott Michael Reynen <scott@randomchaos.com>
- * @link http://www.randomchaos.com/document.php?source=php_and_unicode
- * @see unicode_to_utf8()
- */
-function utf8_to_unicode( $str ) {
- $unicode = array();
- $values = array();
- $lookingFor = 1;
-
- for ($i = 0; $i < strlen( $str ); $i++ ) {
- $thisValue = ord( $str[ $i ] );
- if ( $thisValue < 128 ) $unicode[] = $thisValue;
- else {
- if ( count( $values ) == 0 ) $lookingFor = ( $thisValue < 224 ) ? 2 : 3;
- $values[] = $thisValue;
- if ( count( $values ) == $lookingFor ) {
- $number = ( $lookingFor == 3 ) ?
- ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ):
- ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 );
- $unicode[] = $number;
- $values = array();
- $lookingFor = 1;
- }
- }
- }
- return $unicode;
-}
-
-/**
- * This function will convert a Unicode array back to its UTF-8 representation
- *
- * @author Scott Michael Reynen <scott@randomchaos.com>
- * @link http://www.randomchaos.com/document.php?source=php_and_unicode
- * @see utf8_to_unicode()
- */
-function unicode_to_utf8( $str ) {
- $utf8 = '';
- foreach( $str as $unicode ) {
- if ( $unicode < 128 ) {
- $utf8.= chr( $unicode );
- } elseif ( $unicode < 2048 ) {
- $utf8.= chr( 192 + ( ( $unicode - ( $unicode % 64 ) ) / 64 ) );
- $utf8.= chr( 128 + ( $unicode % 64 ) );
- } else {
- $utf8.= chr( 224 + ( ( $unicode - ( $unicode % 4096 ) ) / 4096 ) );
- $utf8.= chr( 128 + ( ( ( $unicode % 4096 ) - ( $unicode % 64 ) ) / 64 ) );
- $utf8.= chr( 128 + ( $unicode % 64 ) );
- }
- }
- return $utf8;
-}
-
-/**
- * UTF-8 Case lookup table
- *
- * This lookuptable defines the upper case letters to their correspponding
- * lower case letter in UTF-8
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-$UTF8_LOWER_TO_UPPER = array(
- 0x0061=>0x0041, 0x03C6=>0x03A6, 0x0163=>0x0162, 0x00E5=>0x00C5, 0x0062=>0x0042,
- 0x013A=>0x0139, 0x00E1=>0x00C1, 0x0142=>0x0141, 0x03CD=>0x038E, 0x0101=>0x0100,
- 0x0491=>0x0490, 0x03B4=>0x0394, 0x015B=>0x015A, 0x0064=>0x0044, 0x03B3=>0x0393,
- 0x00F4=>0x00D4, 0x044A=>0x042A, 0x0439=>0x0419, 0x0113=>0x0112, 0x043C=>0x041C,
- 0x015F=>0x015E, 0x0144=>0x0143, 0x00EE=>0x00CE, 0x045E=>0x040E, 0x044F=>0x042F,
- 0x03BA=>0x039A, 0x0155=>0x0154, 0x0069=>0x0049, 0x0073=>0x0053, 0x1E1F=>0x1E1E,
- 0x0135=>0x0134, 0x0447=>0x0427, 0x03C0=>0x03A0, 0x0438=>0x0418, 0x00F3=>0x00D3,
- 0x0440=>0x0420, 0x0454=>0x0404, 0x0435=>0x0415, 0x0449=>0x0429, 0x014B=>0x014A,
- 0x0431=>0x0411, 0x0459=>0x0409, 0x1E03=>0x1E02, 0x00F6=>0x00D6, 0x00F9=>0x00D9,
- 0x006E=>0x004E, 0x0451=>0x0401, 0x03C4=>0x03A4, 0x0443=>0x0423, 0x015D=>0x015C,
- 0x0453=>0x0403, 0x03C8=>0x03A8, 0x0159=>0x0158, 0x0067=>0x0047, 0x00E4=>0x00C4,
- 0x03AC=>0x0386, 0x03AE=>0x0389, 0x0167=>0x0166, 0x03BE=>0x039E, 0x0165=>0x0164,
- 0x0117=>0x0116, 0x0109=>0x0108, 0x0076=>0x0056, 0x00FE=>0x00DE, 0x0157=>0x0156,
- 0x00FA=>0x00DA, 0x1E61=>0x1E60, 0x1E83=>0x1E82, 0x00E2=>0x00C2, 0x0119=>0x0118,
- 0x0146=>0x0145, 0x0070=>0x0050, 0x0151=>0x0150, 0x044E=>0x042E, 0x0129=>0x0128,
- 0x03C7=>0x03A7, 0x013E=>0x013D, 0x0442=>0x0422, 0x007A=>0x005A, 0x0448=>0x0428,
- 0x03C1=>0x03A1, 0x1E81=>0x1E80, 0x016D=>0x016C, 0x00F5=>0x00D5, 0x0075=>0x0055,
- 0x0177=>0x0176, 0x00FC=>0x00DC, 0x1E57=>0x1E56, 0x03C3=>0x03A3, 0x043A=>0x041A,
- 0x006D=>0x004D, 0x016B=>0x016A, 0x0171=>0x0170, 0x0444=>0x0424, 0x00EC=>0x00CC,
- 0x0169=>0x0168, 0x03BF=>0x039F, 0x006B=>0x004B, 0x00F2=>0x00D2, 0x00E0=>0x00C0,
- 0x0434=>0x0414, 0x03C9=>0x03A9, 0x1E6B=>0x1E6A, 0x00E3=>0x00C3, 0x044D=>0x042D,
- 0x0436=>0x0416, 0x01A1=>0x01A0, 0x010D=>0x010C, 0x011D=>0x011C, 0x00F0=>0x00D0,
- 0x013C=>0x013B, 0x045F=>0x040F, 0x045A=>0x040A, 0x00E8=>0x00C8, 0x03C5=>0x03A5,
- 0x0066=>0x0046, 0x00FD=>0x00DD, 0x0063=>0x0043, 0x021B=>0x021A, 0x00EA=>0x00CA,
- 0x03B9=>0x0399, 0x017A=>0x0179, 0x00EF=>0x00CF, 0x01B0=>0x01AF, 0x0065=>0x0045,
- 0x03BB=>0x039B, 0x03B8=>0x0398, 0x03BC=>0x039C, 0x045C=>0x040C, 0x043F=>0x041F,
- 0x044C=>0x042C, 0x00FE=>0x00DE, 0x00F0=>0x00D0, 0x1EF3=>0x1EF2, 0x0068=>0x0048,
- 0x00EB=>0x00CB, 0x0111=>0x0110, 0x0433=>0x0413, 0x012F=>0x012E, 0x00E6=>0x00C6,
- 0x0078=>0x0058, 0x0161=>0x0160, 0x016F=>0x016E, 0x03B1=>0x0391, 0x0457=>0x0407,
- 0x0173=>0x0172, 0x00FF=>0x0178, 0x006F=>0x004F, 0x043B=>0x041B, 0x03B5=>0x0395,
- 0x0445=>0x0425, 0x0121=>0x0120, 0x017E=>0x017D, 0x017C=>0x017B, 0x03B6=>0x0396,
- 0x03B2=>0x0392, 0x03AD=>0x0388, 0x1E85=>0x1E84, 0x0175=>0x0174, 0x0071=>0x0051,
- 0x0437=>0x0417, 0x1E0B=>0x1E0A, 0x0148=>0x0147, 0x0105=>0x0104, 0x0458=>0x0408,
- 0x014D=>0x014C, 0x00ED=>0x00CD, 0x0079=>0x0059, 0x010B=>0x010A, 0x03CE=>0x038F,
- 0x0072=>0x0052, 0x0430=>0x0410, 0x0455=>0x0405, 0x0452=>0x0402, 0x0127=>0x0126,
- 0x0137=>0x0136, 0x012B=>0x012A, 0x03AF=>0x038A, 0x044B=>0x042B, 0x006C=>0x004C,
- 0x03B7=>0x0397, 0x0125=>0x0124, 0x0219=>0x0218, 0x00FB=>0x00DB, 0x011F=>0x011E,
- 0x043E=>0x041E, 0x1E41=>0x1E40, 0x03BD=>0x039D, 0x0107=>0x0106, 0x03CB=>0x03AB,
- 0x0446=>0x0426, 0x00FE=>0x00DE, 0x00E7=>0x00C7, 0x03CA=>0x03AA, 0x0441=>0x0421,
- 0x0432=>0x0412, 0x010F=>0x010E, 0x00F8=>0x00D8, 0x0077=>0x0057, 0x011B=>0x011A,
- 0x0074=>0x0054, 0x006A=>0x004A, 0x045B=>0x040B, 0x0456=>0x0406, 0x0103=>0x0102,
- 0x03BB=>0x039B, 0x00F1=>0x00D1, 0x043D=>0x041D, 0x03CC=>0x038C, 0x00E9=>0x00C9,
- 0x00F0=>0x00D0, 0x0457=>0x0407, 0x0123=>0x0122,
-);
-
-/**
- * UTF-8 Case lookup table
- *
- * This lookuptable defines the lower case letters to their correspponding
- * upper case letter in UTF-8 (it does so by flipping $UTF8_LOWER_TO_UPPER)
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-$UTF8_UPPER_TO_LOWER = @array_flip($UTF8_LOWER_TO_UPPER);
-
-/**
- * UTF-8 lookup table for lower case accented letters
- *
- * This lookuptable defines replacements for accented characters from the ASCII-7
- * range. This are lower case letters only.
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @see utf8_deaccent()
- */
-$UTF8_LOWER_ACCENTS = array(
- 'à ' => 'a', 'ô' => 'o', 'Ä\8f' => 'd', 'á¸\9f' => 'f', 'ë' => 'e', 'Å¡' => 's', 'Æ¡' => 'o',
- 'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k',
- 'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o',
- 'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o',
- 'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c',
- 'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't',
- 'ū' => 'u', 'č' => 'c', 'ö' => 'oe', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l',
- 'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z',
- 'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't',
- 'ŗ' => 'r', 'ä' => 'ae', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o',
- 'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j',
- 'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o',
- 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g',
- 'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a',
- 'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u',
-);
-
-/**
- * UTF-8 lookup table for upper case accented letters
- *
- * This lookuptable defines replacements for accented characters from the ASCII-7
- * range. This are upper case letters only.
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @see utf8_deaccent()
- */
-$UTF8_UPPER_ACCENTS = array(
- 'à ' => 'A', 'ô' => 'O', 'Ä\8f' => 'D', 'á¸\9f' => 'F', 'ë' => 'E', 'Å¡' => 'S', 'Æ¡' => 'O',
- 'ß' => 'Ss', 'ă' => 'A', 'ř' => 'R', 'ț' => 'T', 'ň' => 'N', 'ā' => 'A', 'ķ' => 'K',
- 'ŝ' => 'S', 'ỳ' => 'Y', 'ņ' => 'N', 'ĺ' => 'L', 'ħ' => 'H', 'ṗ' => 'P', 'ó' => 'O',
- 'ú' => 'U', 'ě' => 'E', 'é' => 'E', 'ç' => 'C', 'ẁ' => 'W', 'ċ' => 'C', 'õ' => 'O',
- 'ṡ' => 'S', 'ø' => 'O', 'ģ' => 'G', 'ŧ' => 'T', 'ș' => 'S', 'ė' => 'E', 'ĉ' => 'C',
- 'ś' => 'S', 'î' => 'I', 'ű' => 'U', 'ć' => 'C', 'ę' => 'E', 'ŵ' => 'W', 'ṫ' => 'T',
- 'ū' => 'U', 'č' => 'C', 'ö' => 'Oe', 'è' => 'E', 'ŷ' => 'Y', 'ą' => 'A', 'ł' => 'L',
- 'ų' => 'U', 'ů' => 'U', 'ş' => 'S', 'ğ' => 'G', 'ļ' => 'L', 'ƒ' => 'F', 'ž' => 'Z',
- 'ẃ' => 'W', 'ḃ' => 'B', 'å' => 'A', 'ì' => 'I', 'ï' => 'I', 'ḋ' => 'D', 'ť' => 'T',
- 'ŗ' => 'R', 'ä' => 'Ae', 'í' => 'I', 'ŕ' => 'R', 'ê' => 'E', 'ü' => 'Ue', 'ò' => 'O',
- 'ē' => 'E', 'ñ' => 'N', 'ń' => 'N', 'ĥ' => 'H', 'ĝ' => 'G', 'đ' => 'D', 'ĵ' => 'J',
- 'ÿ' => 'Y', 'ũ' => 'U', 'ŭ' => 'U', 'ư' => 'U', 'ţ' => 'T', 'ý' => 'Y', 'ő' => 'O',
- 'â' => 'A', 'ľ' => 'L', 'ẅ' => 'W', 'ż' => 'Z', 'ī' => 'I', 'ã' => 'A', 'ġ' => 'G',
- 'ṁ' => 'M', 'ō' => 'O', 'ĩ' => 'I', 'ù' => 'U', 'į' => 'I', 'ź' => 'Z', 'á' => 'A',
- 'û' => 'U', 'Þ' => 'Th', 'Ð' => 'Dh', 'Æ' => 'Ae',
-);
-
-/**
- * UTF-8 array of common special characters
- *
- * This array should contain all special characters (not a letter or digit)
- * defined in the various local charsets - it's not a complete list of non-alphanum
- * characters in UTF-8. It's not perfect but should match most cases of special
- * chars.
- *
- * The controlchars 0x00 to 0x19 are _not_ included in this array. The space 0x20 is!
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- * @see utf8_stripspecials()
- */
-$UTF8_SPECIAL_CHARS = array(
- 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, 0x0020, 0x0021, 0x0022, 0x0023,
- 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d,
- 0x002e, 0x002f, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, 0x0040, 0x005b,
- 0x005c, 0x005d, 0x005e, 0x005f, 0x0060, 0x0142, 0x007b, 0x007c, 0x007d, 0x007e,
- 0x007f, 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088,
- 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, 0x0090, 0x0091, 0x0092,
- 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c,
- 0x009d, 0x009e, 0x009f, 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6,
- 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, 0x00b0,
- 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba,
- 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, 0x00d7, 0x00f7, 0x02c7, 0x02d8, 0x02d9,
- 0x02da, 0x02db, 0x02dc, 0x02dd, 0x0300, 0x0301, 0x0303, 0x0309, 0x0323, 0x0384,
- 0x0385, 0x0387, 0x03b2, 0x03c6, 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x05b0, 0x05b1,
- 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, 0x05b8, 0x05b9, 0x05bb, 0x05bc,
- 0x05bd, 0x05be, 0x05bf, 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f3, 0x05f4, 0x060c,
- 0x061b, 0x061f, 0x0640, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, 0x0650, 0x0651,
- 0x0652, 0x066a, 0x0e3f, 0x200c, 0x200d, 0x200e, 0x200f, 0x2013, 0x2014, 0x2015,
- 0x2017, 0x2018, 0x2019, 0x201a, 0x201c, 0x201d, 0x201e, 0x2020, 0x2021, 0x2022,
- 0x2026, 0x2030, 0x2032, 0x2033, 0x2039, 0x203a, 0x2044, 0x20a7, 0x20aa, 0x20ab,
- 0x20ac, 0x2116, 0x2118, 0x2122, 0x2126, 0x2135, 0x2190, 0x2191, 0x2192, 0x2193,
- 0x2194, 0x2195, 0x21b5, 0x21d0, 0x21d1, 0x21d2, 0x21d3, 0x21d4, 0x2200, 0x2202,
- 0x2203, 0x2205, 0x2206, 0x2207, 0x2208, 0x2209, 0x220b, 0x220f, 0x2211, 0x2212,
- 0x2215, 0x2217, 0x2219, 0x221a, 0x221d, 0x221e, 0x2220, 0x2227, 0x2228, 0x2229,
- 0x222a, 0x222b, 0x2234, 0x223c, 0x2245, 0x2248, 0x2260, 0x2261, 0x2264, 0x2265,
- 0x2282, 0x2283, 0x2284, 0x2286, 0x2287, 0x2295, 0x2297, 0x22a5, 0x22c5, 0x2310,
- 0x2320, 0x2321, 0x2329, 0x232a, 0x2469, 0x2500, 0x2502, 0x250c, 0x2510, 0x2514,
- 0x2518, 0x251c, 0x2524, 0x252c, 0x2534, 0x253c, 0x2550, 0x2551, 0x2552, 0x2553,
- 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d,
- 0x255e, 0x255f, 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567,
- 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590,
- 0x2591, 0x2592, 0x2593, 0x25a0, 0x25b2, 0x25bc, 0x25c6, 0x25ca, 0x25cf, 0x25d7,
- 0x2605, 0x260e, 0x261b, 0x261e, 0x2660, 0x2663, 0x2665, 0x2666, 0x2701, 0x2702,
- 0x2703, 0x2704, 0x2706, 0x2707, 0x2708, 0x2709, 0x270c, 0x270d, 0x270e, 0x270f,
- 0x2710, 0x2711, 0x2712, 0x2713, 0x2714, 0x2715, 0x2716, 0x2717, 0x2718, 0x2719,
- 0x271a, 0x271b, 0x271c, 0x271d, 0x271e, 0x271f, 0x2720, 0x2721, 0x2722, 0x2723,
- 0x2724, 0x2725, 0x2726, 0x2727, 0x2729, 0x272a, 0x272b, 0x272c, 0x272d, 0x272e,
- 0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738,
- 0x2739, 0x273a, 0x273b, 0x273c, 0x273d, 0x273e, 0x273f, 0x2740, 0x2741, 0x2742,
- 0x2743, 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274a, 0x274b, 0x274d,
- 0x274f, 0x2750, 0x2751, 0x2752, 0x2756, 0x2758, 0x2759, 0x275a, 0x275b, 0x275c,
- 0x275d, 0x275e, 0x2761, 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x277f,
- 0x2789, 0x2793, 0x2794, 0x2798, 0x2799, 0x279a, 0x279b, 0x279c, 0x279d, 0x279e,
- 0x279f, 0x27a0, 0x27a1, 0x27a2, 0x27a3, 0x27a4, 0x27a5, 0x27a6, 0x27a7, 0x27a8,
- 0x27a9, 0x27aa, 0x27ab, 0x27ac, 0x27ad, 0x27ae, 0x27af, 0x27b1, 0x27b2, 0x27b3,
- 0x27b4, 0x27b5, 0x27b6, 0x27b7, 0x27b8, 0x27b9, 0x27ba, 0x27bb, 0x27bc, 0x27bd,
- 0x27be, 0xf6d9, 0xf6da, 0xf6db, 0xf8d7, 0xf8d8, 0xf8d9, 0xf8da, 0xf8db, 0xf8dc,
- 0xf8dd, 0xf8de, 0xf8df, 0xf8e0, 0xf8e1, 0xf8e2, 0xf8e3, 0xf8e4, 0xf8e5, 0xf8e6,
- 0xf8e7, 0xf8e8, 0xf8e9, 0xf8ea, 0xf8eb, 0xf8ec, 0xf8ed, 0xf8ee, 0xf8ef, 0xf8f0,
- 0xf8f1, 0xf8f2, 0xf8f3, 0xf8f4, 0xf8f5, 0xf8f6, 0xf8f7, 0xf8f8, 0xf8f9, 0xf8fa,
- 0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0xfe7c, 0xfe7d,
-);
-?>
--- /dev/null
+2007-08-12 03:20 tag RELEASE_0_5
+
+2007-08-12 03:20 harryf
+
+ * str_ireplace.php, tests/cases/utf8_str_ireplace.test.php: Fix
+ 1599859 at last -
+ http://sourceforge.net/tracker/index.php?func=detail&aid=1599859&group_id=142846&atid=753842
+
+2007-08-12 03:11 harryf
+
+ * native/core.php: Limit the number parts to two when exploding
+ which may give a small performance gain and reduce memory use -
+ thanks to Geert De Deckere for tip
+
+2006-10-25 16:57 tag RELEASE_0_4
+
+2006-10-25 16:57 harryf
+
+ * docs/examples/tables.php: Add sample for lookup tables
+
+2006-10-17 11:58 harryf
+
+ * tests/cases/utf8_unicode.test.php: Add basic sanity checks
+
+2006-10-17 11:48 harryf
+
+ * native/core.php: Move lookup tables to local statics instead of
+ globals
+
+2006-10-17 11:22 harryf
+
+ * tests/cases/: utf8_strtoupper.test.php,
+ utf8_substr_replace.test.php: Fix class names when run tests
+ individually
+
+2006-10-17 11:09 harryf
+
+ * tests/cases/utf8_specials.test.php: Add tests for
+ utf8_is_word_chars
+
+2006-10-17 10:53 harryf
+
+ * tests/cases/utf8_ascii.test.php: Add test for empty string
+
+2006-10-17 10:53 harryf
+
+ * tests/cases/utf8_specials.test.php: Add utf8_strip_specials tests
+
+2006-10-16 23:13 harryf
+
+ * utils/specials.php: Eliminate the global
+
+2006-10-16 22:39 harryf
+
+ * tests/cases/utf8_ascii.test.php: Add basic tests for
+ utf8_accents_to_ascii
+
+2006-10-16 22:38 harryf
+
+ * utils/ascii.php: Fix bug 1568924 plus make this function actually
+ do something - used correct lookup tables, s/$string/$str - guess
+ no one using it yet, so no complaints ;)
+
+2006-10-01 02:01 tag RELEASE_0_3
+
+2006-10-01 02:01 harryf
+
+ * utils/position.php: Add Chris Smiths implementation - given str
+ and UTF-8 chr pos, returns corresponding byte index
+
+2006-10-01 01:53 harryf
+
+ * tests/cases/utf8_ascii.test.php: Update to reflect change to
+ is_ascii - returning TRUE on empty strings
+
+2006-10-01 01:51 harryf
+
+ * utils/ascii.php: Change is_ascii test - returns true on empty
+ strings - also changed regex so it doesnt capture matches in
+ memory
+
+2006-10-01 01:38 harryf
+
+ * docs/phputf8.pod: Few extra links
+
+2006-10-01 01:16 harryf
+
+ * TODO.tsk: Task update
+
+2006-10-01 01:16 harryf
+
+ * README: Update note on license re Dokuwiki
+
+2006-10-01 01:16 harryf
+
+ * DEPENDENCIES: Redundant
+
+2006-10-01 01:02 harryf
+
+ * tests/data/bench/: strlen_mbstring_20061001.txt,
+ strlen_native_20061001.txt, strpos_mbstring_20061001.txt,
+ strpos_native_20061001.txt, strrpos_mbstring_20061001.txt,
+ strrpos_native_20061001.txt, substr_mbstring_20061001.txt,
+ substr_native_20061001.txt: Latest benchmarks
+
+2006-10-01 00:51 harryf
+
+ * tests/cases/utf8_substr.test.php: Test overlong length
+
+2006-10-01 00:49 harryf
+
+ * tests/cases/utf8_position.test.php: Tests for charpos to bytepos
+ fns
+
+2006-09-30 15:17 harryf
+
+ * native/core.php: Another implementation thanks to Chris Smith /
+ dokuwiki, solving 65535 bug while preserving performance, plus
+ handling negative offset, lengths
+
+2006-09-27 23:34 harryf
+
+ * native/core.php: Tentatively checking in a bugfixed version of
+ utf8_substr, now able to cope with 65535 - bug 1547780.
+
+2006-09-11 17:22 harryf
+
+ * ord.php: Fix error reporting - zero index
+
+2006-09-11 17:14 harryf
+
+ * utf8.php: Add runtime check to confirm PCRE is compiled with
+ UTF-8 support
+
+2006-09-03 11:25 harryf
+
+ * str_pad.php, tests/cases/utf8_str_pad.test.php: Adding Oliver
+ Saunders str_pad implementation
+
+2006-04-09 23:22 harryf
+
+ * ord.php: Add sequence length checks
+
+2006-03-27 23:02 harryf
+
+ * tests/cases/utf8_ascii.test.php: Add sanity tests
+
+2006-03-27 23:02 harryf
+
+ * utils/ascii.php: Add note on use of utf8_strip_ascii_ctrl
+
+2006-03-27 00:26 harryf
+
+ * tests/cases/utf8_ord.test.php: Add some tests for utf8_ord
+
+2006-03-27 00:25 harryf
+
+ * ord.php: Further reduce num calls to ord
+
+2006-03-21 01:50 harryf
+
+ * docs/: makeDocs.pl, print.css, screen.css: Supporting doc stuff
+
+2006-03-19 00:30 harryf
+
+ * docs/phputf8.pod: First pass on docs complete
+
+2006-03-18 14:32 harryf
+
+ * docs/phputf8.pod: More of handling bad bytes
+
+2006-03-18 13:47 tag RELEASE_0_2
+
+2006-03-18 13:47 harryf
+
+ * utils/ascii.php: Initial implementation of ctrl codes stripper -
+ better done with preg_replace?
+
+2006-03-18 00:55 harryf
+
+ * docs/phputf8.pod: fix pod syntax
+
+2006-03-18 00:37 harryf
+
+ * docs/phputf8.pod: A little more on validation - poorly written
+ but anyway
+
+2006-03-18 00:36 harryf
+
+ * README, TODO.tsk: Stay up to date
+
+2006-03-18 00:36 harryf
+
+ * ord.php: Adding ord for utf-8
+
+2006-03-17 00:04 harryf
+
+ * docs/phputf8.pod: Adding place holders
+
+2006-03-16 23:57 harryf
+
+ * docs/phputf8.pod: Getting started on docs
+
+2006-02-28 23:12 harryf
+
+ * utf8.php, mbstring/case.php, mbstring/core.php,
+ mbstring/strlen.php, native/case.php, native/core.php,
+ native/strlen.php, tests/benchconfig.php, tests/config.php:
+ Reduce the number of includes
+
+2006-02-27 11:01 harryf
+
+ * tests/: benchconfig.php, config.php: Remove superflous defines
+
+2006-02-27 01:00 harryf
+
+ * ascii.php, bad.php, unicode.php, validation.php: Remove outdated
+ files
+
+2006-02-27 00:59 tag RELEASE_0_1
+
+2006-02-27 00:59 harryf
+
+ * native/strlen.php: Add newline at end
+
+2006-02-27 00:58 harryf
+
+ * docs/examples/1.php: Add example of validation
+
+2006-02-27 00:56 harryf
+
+ * docs/examples/1.php: Add simple example
+
+2006-02-27 00:46 harryf
+
+ * TODO.tsk: Update TODO list
+
+2006-02-27 00:38 harryf
+
+ * tests/benchconfig.php, tests/config.php, tests/index.php,
+ utf8.php: Eliminate iconv
+
+2006-02-27 00:37 harryf
+
+ * tests/data/bench/: strlen_mbstring_20060226.txt,
+ strlen_native_20060226.txt, strpos_mbstring_20060226.txt,
+ strpos_native_20060226.txt, strrpos_mbstring_20060226.txt,
+ strrpos_native_20060226.txt, substr_mbstring_20060226.txt,
+ substr_native_20060226.txt: Add benchmark results
+
+2006-02-27 00:37 harryf
+
+ * tests/bench/substr.php: Add substr bench
+
+2006-02-27 00:17 harryf
+
+ * tests/bench/: strpos.php, strrpos.php: Add benchmark scripts for
+ strpos and strrpos
+
+2006-02-26 23:15 harryf
+
+ * tests/: benchconfig.php, config.php, bench/strlen.php: Rejigging
+ around mb_strlen and starting benchmarks
+
+2006-02-26 23:13 harryf
+
+ * utf8.php: Place higher priority on mbstring
+
+2006-02-26 23:13 harryf
+
+ * mbstring/: README, strlen.php: Adding mb_strlen implementation
+
+2006-02-26 22:47 harryf
+
+ * tests/config.php: Make sure encoding is set correctly
+
+2006-02-26 15:07 harryf
+
+ * tests/: config.php, index.php, runtests.php: Allow any test to
+ run against a particular engine
+
+2006-02-26 14:56 harryf
+
+ * README: More README notes
+
+2006-02-26 14:39 harryf
+
+ * tests/cases/: utf8_ascii.test.php, utf8_bad.test.php,
+ utf8_validation.test.php: New file locations
+
+2006-02-26 14:39 harryf
+
+ * tests/: index.php, runtests.php: Add option to run against
+ specific engine
+
+2006-02-26 14:20 harryf
+
+ * utils/: bad.php, unicode.php, validation.php: PHP @version doc
+ tags
+
+2006-02-26 14:17 harryf
+
+ * utils/: ascii.php, bad.php, specials.php, unicode.php, utils.php,
+ validation.php: More moving files around
+
+2006-02-26 14:07 harryf
+
+ * tests/cases/: utf8_ucfirst.test.php, utf8_ucwords.test.php: test
+ for one char only
+
+2006-02-25 15:52 harryf
+
+ * tests/cases/: utf8_ascii.test.php, utf8_bad.test.php,
+ utf8_str_ireplace.test.php, utf8_str_split.test.php,
+ utf8_strcasecmp.test.php, utf8_strcspn.test.php,
+ utf8_stristr.test.php, utf8_strrev.test.php,
+ utf8_strspn.test.php, utf8_substr_replace.test.php,
+ utf8_trim.test.php, utf8_ucfirst.test.php, utf8_ucwords.test.php,
+ utf8_validation.test.php: Modify to reflect file / constant
+ renaming
+
+2006-02-25 15:28 harryf
+
+ * tests/cases/: utf8_native_str_ireplace.test.php,
+ utf8_native_str_split.test.php, utf8_native_strcasecmp.test.php,
+ utf8_native_strcspn.test.php, utf8_native_stristr.test.php,
+ utf8_native_strrev.test.php, utf8_native_strspn.test.php,
+ utf8_native_substr_replace.test.php, utf8_native_trim.test.php,
+ utf8_native_ucfirst.test.php, utf8_native_ucwords.test.php,
+ utf8_str_ireplace.test.php, utf8_str_split.test.php,
+ utf8_strcasecmp.test.php, utf8_strcspn.test.php,
+ utf8_stristr.test.php, utf8_strrev.test.php,
+ utf8_strspn.test.php, utf8_substr_replace.test.php,
+ utf8_trim.test.php, utf8_ucfirst.test.php, utf8_ucwords.test.php:
+ Renaming test files
+
+2006-02-25 15:22 harryf
+
+ * tests/config.php: Use correct constant, remove set encodings
+
+2006-02-25 15:20 harryf
+
+ * ascii.php, bad.php, unicode.php, utf8_ascii.php, utf8_bad.php,
+ utf8_patterns.php, utf8_unicode.php, utf8_utils.php,
+ utf8_validation.php, validation.php, utils/patterns.php,
+ utils/utils.php: File renaming
+
+2006-02-25 15:14 harryf
+
+ * utf8.php: Rename directory constant and use control constants
+
+2006-02-25 15:07 harryf
+
+ * mbstring/: core.php, case.php: Add docs / control constant
+
+2006-02-25 15:05 harryf
+
+ * mbstring/README: Add note for the picky
+
+2006-02-25 14:54 harryf
+
+ * native/: case.php, core.php, strlen.php: Add control constants
+
+2006-02-25 14:50 harryf
+
+ * native/: utf8_str_ireplace.php, utf8_str_split.php,
+ utf8_strcasecmp.php, utf8_strcspn.php, utf8_stristr.php,
+ utf8_strrev.php, utf8_strspn.php, utf8_substr_replace.php,
+ utf8_trim.php, utf8_ucfirst.php, utf8_ucwords.php: Moved to
+ parent directory
+
+2006-02-25 14:50 harryf
+
+ * str_ireplace.php, str_split.php, strcasecmp.php, strcspn.php,
+ stristr.php, strrev.php, strspn.php, substr_replace.php,
+ trim.php, ucfirst.php, ucwords.php: Renaming / moving from native
+ subdir
+
+2006-02-25 14:28 harryf
+
+ * native/strlen.php: Add constant to control loading
+
+2006-02-25 14:26 harryf
+
+ * native/: strlen.php, utf8_strlen.php: Begin file renaming
+
+2006-02-25 14:21 harryf
+
+ * native/utf8_ucfirst.php: Bug fixes so tests pass
+
+2006-02-25 00:43 harryf
+
+ * utf8.php: Modify to reflect native/core.php and native/case.php
+
+2006-02-25 00:42 harryf
+
+ * tests/config.php: Make sure HTMLReporter is producing UTF-8
+
+2006-02-25 00:39 harryf
+
+ * tests/index.php: Add simple browser for tests
+
+2006-02-25 00:33 harryf
+
+ * tests/cases/: utf8_ascii.test.php,
+ utf8_native_str_ireplace.test.php,
+ utf8_native_str_split.test.php, utf8_native_strcasecmp.test.php,
+ utf8_native_strcspn.test.php, utf8_native_stristr.test.php,
+ utf8_native_strrev.test.php, utf8_native_strspn.test.php,
+ utf8_native_substr_replace.test.php, utf8_native_trim.test.php,
+ utf8_native_ucfirst.test.php, utf8_native_ucwords.test.php,
+ utf8_strlen.test.php, utf8_strpos.test.php,
+ utf8_strrpos.test.php, utf8_strtolower.test.php,
+ utf8_strtoupper.test.php, utf8_substr.test.php,
+ utf8_validation.test.php: Fix copy and paste gotchas
+
+2006-02-25 00:32 harryf
+
+ * tests/runtests.php: Add runner for all tests
+
+2006-02-25 00:08 harryf
+
+ * tests/cases/utf8_bad.test.php: Fix constant, modify way
+ config.php is loaded
+
+2006-02-25 00:06 harryf
+
+ * tests/cases/utf8_ascii.test.php: Correct constant and test name
+
+2006-02-25 00:04 harryf
+
+ * tests/cases/: utf8_strtolower.test.php, utf8_strtoupper.test.php:
+ Correct test names
+
+2006-02-25 00:02 harryf
+
+ * native/: case.php, utf8_strtolower.php, utf8_strtoupper.php: Move
+ utf8_strtoupper and utf8_strtolower into case.php
+
+2006-02-24 23:59 harryf
+
+ * native/: utf8_strpos.php, utf8_strrpos.php, utf8_substr.php:
+ Remove files now merged into native/core.php
+
+2006-02-24 23:57 harryf
+
+ * native/core.php: Moving utf8_strpos, utf8_strrpos and utf8_substr
+ to single file
+
+2006-02-24 23:51 harryf
+
+ * TODO.tsk: Add todo list
+
+2006-02-24 23:36 harryf
+
+ * native/utf8_substr.php: Handle lengths beyond end of string in
+ same way as substr
+
+2006-02-24 23:35 harryf
+
+ * tests/cases/utf8_substr.test.php: Adjusts tests to expect same
+ behaviour as substr
+
+2006-02-24 23:12 harryf
+
+ * utf8.php: Replace variable containing directory with constant
+
+2006-02-24 23:06 harryf
+
+ * tests/cases/: utf8_strrpos.test.php, utf8_substr.test.php: Remove
+ requires
+
+2006-02-24 22:56 harryf
+
+ * tests/config.php: Load core functions via utf8.php
+
+2006-02-24 22:55 harryf
+
+ * tests/cases/: utf8_native_strlen.test.php,
+ utf8_native_strpos.test.php, utf8_native_strrpos.test.php,
+ utf8_native_strtolower.test.php, utf8_native_strtoupper.test.php,
+ utf8_native_substr.test.php, utf8_strlen.test.php,
+ utf8_strpos.test.php, utf8_strrpos.test.php,
+ utf8_strtolower.test.php, utf8_strtoupper.test.php,
+ utf8_substr.test.php: Begin test reorganisation
+
+2006-02-24 22:53 harryf
+
+ * utf8_patterns.php: Add note that not used by rest of lib
+
+2006-02-24 22:52 harryf
+
+ * utf8_bad.php: Embed bad regex in functions to eliminate include
+
+2006-02-24 16:13 harryf
+
+ * DEPENDENCIES: Starting on dependency documentation
+
+2006-02-24 16:06 harryf
+
+ * native/utf8_substr_replace.php: Document dependency on
+ utf8_strlen
+
+2006-02-24 16:03 harryf
+
+ * native/utf8_substr.php: Fix error reporting
+
+2006-02-24 15:58 harryf
+
+ * README: Add note on bug reporting and well formed utf8
+
+2006-02-24 15:45 harryf
+
+ * native/utf8_strrpos.php: Document dependency on utf8_strlen,
+ utf8_substr
+
+2006-02-24 15:28 harryf
+
+ * native/utf8_strpos.php: Document dependency on utf8_strlen,
+ utf8_substr
+
+2006-02-24 15:25 harryf
+
+ * native/utf8_stristr.php: Document dependency on utf8_strlen
+
+2006-02-24 15:22 harryf
+
+ * native/utf8_strcasecmp.php: Document dependency on
+ utf8_strtolower
+
+2006-02-24 15:21 harryf
+
+ * native/: utf8_str_split.php, utf8_strcspn.php: Document
+ dependency on utf8_strlen
+
+2006-02-24 15:18 harryf
+
+ * native/: case.php, core.php: Remove unneeded files
+
+2006-02-24 15:16 harryf
+
+ * README: Add a tiny bit of documentation
+
+2006-02-24 15:12 harryf
+
+ * utf8.php: Add further notes on loading code
+
+2006-02-24 15:11 harryf
+
+ * LICENSE, README: Add license and notes on license
+
+2006-02-24 15:02 harryf
+
+ * utf8_unicode.php, utf8_validation.php, utf8_bad.php: Add better
+ attribution to license blocks
+
+2006-02-24 14:52 harryf
+
+ * mbstring/core.php: Add support for offset to utf8_strrpos
+
+2006-02-24 14:52 harryf
+
+ * native/utf8_strrpos.php: Change E_USER_ERROR to E_USER_WARNING to
+ match strrpos behaviour
+
+2005-12-09 22:32 harryf
+
+ * mbstring/core.php: Switch to assume correct internal encoding
+
+2005-12-09 22:31 harryf
+
+ * utf8_validation.php: Add further comments on 5 / 6 byte sequence
+ risks
+
+2005-12-09 22:29 harryf
+
+ * mbstring/case.php: Add strtolower / upper wrappers
+
+2005-12-09 22:23 harryf
+
+ * README: Fix linefeed issues with README
+
+2005-12-08 17:17 harryf
+
+ * exp/regexunicode.php: Update so its actually working
+
+2005-12-08 17:00 harryf
+
+ * utf8.php: Get this to a semi-working condition
+
+2005-12-08 16:44 harryf
+
+ * common.php: Remove outdated common.php code
+
+2005-12-08 16:24 harryf
+
+ * native/utf8_ucwords.php: Switch to use of preg_replace_callback
+
+2005-12-08 13:13 harryf
+
+ * utf8_bad.php: Modified to load the patterns file
+
+2005-12-08 13:08 harryf
+
+ * README: Add some notes to README
+
+2005-12-08 12:53 harryf
+
+ * utf8_ascii.php: Add seperate implementations with or without
+ ASCII device control codes
+
+2005-12-08 12:49 harryf
+
+ * utf8_utils.php: Adding utils from andreas gohr / dokuwiki
+
+2005-07-16 13:53 harryf
+
+ * utf8_unicode.php: Fix phpdoc issue
+
+2005-07-16 13:53 harryf
+
+ * utf8_bad.php: Fix bug when for incomplete sequence at end of
+ string and add a bunch of phpdoc comments
+
+2005-07-16 13:36 harryf
+
+ * tests/cases/utf8_bad.test.php: Add some tests for
+ utf8_bad_identify - two failing
+
+2005-07-16 13:20 harryf
+
+ * tests/cases/utf8_validation.test.php: Add tests for
+ utf8_compliant function
+
+2005-07-16 13:12 harryf
+
+ * utf8_validation.php: Add alternative, faster but less strict
+ mechanism to validate a UTF-8 string
+
+2005-07-16 00:03 harryf
+
+ * utf8_bad.php: Add routine to identify how the UTF-8 is bad
+
+2005-07-16 00:01 harryf
+
+ * utf8_validation.php: Minor cleaning
+
+2005-07-15 22:49 harryf
+
+ * utf8_patterns.php: Add api doc note to all patterns that ASCII
+ range has changed from original version
+
+2005-07-15 22:47 harryf
+
+ * tests/cases/utf8_bad.test.php: Add a whole load more tests for
+ specific badly formed UTF-8
+
+2005-07-15 22:46 harryf
+
+ * utf8_patterns.php: Modify patterns to contain full ASCII range
+
+2005-07-15 17:16 harryf
+
+ * tests/cases/utf8_validation.test.php: Add a bunch more tests for
+ specific invalid UTF-8 sequences and code points
+
+2005-07-15 17:15 harryf
+
+ * utf8_validation.php: Dropping regex based implementation and
+ switching to implementation based on that from
+ http://hsivonen.iki.fi/php-utf8/
+
+2005-07-15 14:27 harryf
+
+ * native/utf8_ucwords.php: Add a little documentation of the regex
+
+2005-07-15 14:20 harryf
+
+ * tests/cases/: utf8_native_ucfirst.test.php,
+ utf8_native_ucwords.test.php: Add linefeed tests
+
+2005-07-15 14:12 harryf
+
+ * tests/cases/utf8_native_trim.test.php: Add linefeed tests
+
+2005-07-15 14:03 harryf
+
+ * native/utf8_substr_replace.php: Handle linefeeds correctly
+
+2005-07-15 14:02 harryf
+
+ * tests/cases/utf8_native_substr_replace.test.php: Add linefeed
+ test
+
+2005-07-15 13:58 harryf
+
+ * tests/cases/utf8_native_substr.test.php: Add test of length
+ beyond string length
+
+2005-07-15 13:21 harryf
+
+ * tests/cases/utf8_native_substr.test.php: Add linefeed test
+
+2005-07-15 13:14 harryf
+
+ * tests/config.php: Update for PHP 4.4.0 and new error notice
+
+2005-07-12 09:44 harryf
+
+ * tests/cases/utf8_native_strrpos.test.php: Add linefeed tests
+
+2005-07-12 09:44 harryf
+
+ * native/utf8_strrpos.php: Remove commented print_r statement
+
+2005-07-12 09:40 harryf
+
+ * native/utf8_strrev.php: Modify regex to handle linefeeds
+
+2005-07-12 09:39 harryf
+
+ * tests/cases/utf8_native_strrev.test.php: Add linefeed test
+
+2005-07-12 09:36 harryf
+
+ * tests/cases/: utf8_native_strcspn.test.php,
+ utf8_native_strspn.test.php: Add linefeed tests
+
+2005-07-12 09:32 harryf
+
+ * native/utf8_str_split.php: Modify regex to handle linefeeds and
+ avoid adding null chars to end of string
+
+2005-07-12 09:26 harryf
+
+ * tests/cases/utf8_native_str_split.test.php: Add test with
+ linefeeds
+
+2005-07-11 14:33 harryf
+
+ * tests/cases/utf8_native_str_ireplace.test.php: Add linefeed tests
+
+2005-07-11 14:32 harryf
+
+ * native/utf8_str_ireplace.php: Make regex . meta match new lines
+
+2005-07-11 14:17 harryf
+
+ * native/: utf8_strcasecmp.php, utf8_stristr.php: utf-8
+ implementations of stristr and strcasecmp
+
+2005-07-11 14:16 harryf
+
+ * tests/cases/: utf8_native_strcasecmp.test.php,
+ utf8_native_stristr.test.php: Add tests
+
+2005-07-11 12:48 harryf
+
+ * tests/cases/utf8_native_strcspn.test.php: Add further ascii test
+
+2005-07-11 12:47 harryf
+
+ * tests/cases/: utf8_native_strcspn.test.php,
+ utf8_native_strspn.test.php: Adding tests for utf8_strcspn and
+ correction to utf8_strspn
+
+2005-07-11 12:46 harryf
+
+ * native/: utf8_strcspn.php, utf8_strspn.php: Add missing /u
+ modifier to PCRE patterns
+
+2005-07-05 00:30 tag start
+
+2005-07-05 00:30 harryf
+
+ * README, common.php, utf8.php, utf8_ascii.php, utf8_bad.php,
+ utf8_patterns.php, utf8_unicode.php, utf8_validation.php,
+ exp/regexunicode.php, mbstring/core.php, native/case.php,
+ native/core.php, native/utf8_str_ireplace.php,
+ native/utf8_str_split.php, native/utf8_strcspn.php,
+ native/utf8_strlen.php, native/utf8_strpos.php,
+ native/utf8_strrev.php, native/utf8_strrpos.php,
+ native/utf8_strspn.php, native/utf8_strtolower.php,
+ native/utf8_strtoupper.php, native/utf8_substr.php,
+ native/utf8_substr_replace.php, native/utf8_trim.php,
+ native/utf8_ucfirst.php, native/utf8_ucwords.php,
+ tests/cli_reporter.php, tests/config.php,
+ tests/cases/utf8_ascii.test.php, tests/cases/utf8_bad.test.php,
+ tests/cases/utf8_native_str_ireplace.test.php,
+ tests/cases/utf8_native_str_split.test.php,
+ tests/cases/utf8_native_strlen.test.php,
+ tests/cases/utf8_native_strpos.test.php,
+ tests/cases/utf8_native_strrev.test.php,
+ tests/cases/utf8_native_strrpos.test.php,
+ tests/cases/utf8_native_strspn.test.php,
+ tests/cases/utf8_native_strtolower.test.php,
+ tests/cases/utf8_native_strtoupper.test.php,
+ tests/cases/utf8_native_substr.test.php,
+ tests/cases/utf8_native_substr_replace.test.php,
+ tests/cases/utf8_native_trim.test.php,
+ tests/cases/utf8_native_ucfirst.test.php,
+ tests/cases/utf8_native_ucwords.test.php,
+ tests/cases/utf8_validation.test.php, tests/data/utf8.html:
+ Initial import
+
+2005-07-05 00:30 harryf
+
+ * README, common.php, utf8.php, utf8_ascii.php, utf8_bad.php,
+ utf8_patterns.php, utf8_unicode.php, utf8_validation.php,
+ exp/regexunicode.php, mbstring/core.php, native/case.php,
+ native/core.php, native/utf8_str_ireplace.php,
+ native/utf8_str_split.php, native/utf8_strcspn.php,
+ native/utf8_strlen.php, native/utf8_strpos.php,
+ native/utf8_strrev.php, native/utf8_strrpos.php,
+ native/utf8_strspn.php, native/utf8_strtolower.php,
+ native/utf8_strtoupper.php, native/utf8_substr.php,
+ native/utf8_substr_replace.php, native/utf8_trim.php,
+ native/utf8_ucfirst.php, native/utf8_ucwords.php,
+ tests/cli_reporter.php, tests/config.php,
+ tests/cases/utf8_ascii.test.php, tests/cases/utf8_bad.test.php,
+ tests/cases/utf8_native_str_ireplace.test.php,
+ tests/cases/utf8_native_str_split.test.php,
+ tests/cases/utf8_native_strlen.test.php,
+ tests/cases/utf8_native_strpos.test.php,
+ tests/cases/utf8_native_strrev.test.php,
+ tests/cases/utf8_native_strrpos.test.php,
+ tests/cases/utf8_native_strspn.test.php,
+ tests/cases/utf8_native_strtolower.test.php,
+ tests/cases/utf8_native_strtoupper.test.php,
+ tests/cases/utf8_native_substr.test.php,
+ tests/cases/utf8_native_substr_replace.test.php,
+ tests/cases/utf8_native_trim.test.php,
+ tests/cases/utf8_native_ucfirst.test.php,
+ tests/cases/utf8_native_ucwords.test.php,
+ tests/cases/utf8_validation.test.php, tests/data/utf8.html:
+ Initial revision
+
--- /dev/null
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+\f
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+\f
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
--- /dev/null
+++PHP UTF-8++\r
+\r
+Version 0.5\r
+\r
+++DOCUMENTATION++\r
+\r
+Documentation in progress in ./docs dir\r
+\r
+http://www.phpwact.org/php/i18n/charsets\r
+http://www.phpwact.org/php/i18n/utf-8\r
+\r
+Important Note: DO NOT use these functions without understanding WHY\r
+you are using them. In particular, do not blindly replace all use of PHP's\r
+string functions which functions found here - most of the time you will\r
+not need to, and you will be introducing a significant performance\r
+overhead to your application. You can get a good idea of when to use what\r
+from reading: http://www.phpwact.org/php/i18n/utf-8\r
+\r
+Important Note: For sake of performance most of the functions here are\r
+not "defensive" (e.g. there is not extensive parameter checking, well\r
+formed UTF-8 is assumed). This is particularily relevant when is comes to\r
+catching badly formed UTF-8 - you should screen input on the "outer\r
+perimeter" with help from functions in the utf8_validation.php and\r
+utf8_bad.php files.\r
+\r
+Important Note: this library treats ALL ASCII characters as valid, including ASCII control characters. But if you use some ASCII control characters in XML, it will render the XML ill-formed. Don't be a bozo: http://hsivonen.iki.fi/producing-xml/#controlchar\r
+\r
+++BUGS / SUPPORT / FEATURE REQUESTS ++\r
+\r
+Please report bugs to:\r
+http://sourceforge.net/tracker/?group_id=142846&atid=753842\r
+- if you are able, please submit a failing unit test\r
+(http://www.lastcraft.com/simple_test.php) with your bug report.\r
+\r
+For feature requests / faster implementation of functions found here,\r
+please drop them in via the RFE tracker: http://sourceforge.net/tracker/?group_id=142846&atid=753845\r
+Particularily interested in faster implementations!\r
+\r
+For general support / help, use:\r
+http://sourceforge.net/tracker/?group_id=142846&atid=753843\r
+\r
+In the VERY WORST case, you can email me: hfuecks gmail com - I tend to be slow to respond though so be warned.\r
+\r
+Important Note: when reporting bugs, please provide the following \r
+information;\r
+\r
+PHP version, whether the iconv extension is loaded (in PHP5 it's \r
+there by default), whether the mbstring extension is loaded. The\r
+following PHP script can be used to determine this information;\r
+\r
+<?php\r
+print "PHP Version: " .phpversion()."<br>";\r
+if ( extension_loaded('mbstring') ) {\r
+ print "mbstring available<br>";\r
+} else {\r
+ print "mbstring not available<br>";\r
+}\r
+if ( extension_loaded('iconv') ) {\r
+ print "iconv available<br>";\r
+} else {\r
+ print "iconv not available<br>";\r
+}\r
+?>\r
+\r
+++LICENSING++\r
+\r
+Parts of the code in this library come from other places, under different\r
+licenses.\r
+The authors involved have been contacted (see below). Attribution for\r
+which code came from elsewhere can be found in the source code itself.\r
+\r
++Andreas Gohr / Chris Smith - Dokuwiki\r
+There is a fair degree of collaboration / exchange of ideas and code\r
+beteen Dokuwiki's UTF-8 library;\r
+http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php\r
+and phputf8. Although Dokuwiki is released under GPL, its UTF-8\r
+library is released under LGPL, hence no conflict with phputf8\r
+\r
++Henri Sivonen (http://hsivonen.iki.fi/php-utf8/ / \r
+http://hsivonen.iki.fi/php-utf8/) has also given permission for his\r
+code to be released under the terms of the LGPL. He ported a Unicode / UTF-8\r
+converter from the Mozilla codebase to PHP, which is re-used in phputf8\r
--- /dev/null
+<?xml version="1.0" ?>
+<?taskcoach release="0.54" tskversion="11"?><tasks><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1240074388:1140821052.47" lastModificationTime="2006-10-01 01:13:00.188663" priority="0" startdate="2006-02-24" subject="Documentation"><description> </description><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0" hourlyFee="0" id="-1264484308:1159657959.84" lastModificationTime="2006-10-01 01:13:00.187609" priority="0" startdate="2006-10-01" subject="Pointer to Mediawiki normalization library"><description> </description></task></task><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1237926644:1140820867.74" lastModificationTime="2006-10-01 01:09:05.107323" priority="0" startdate="2006-02-24" subject="Benchmarks"><description>Benchmark different implementations of functions against each other</description><task budget="0:00:00" completiondate="2006-02-27" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1239707828:1140820908.17" lastModificationTime="2006-02-27 00:41:40.253128" priority="0" startdate="2006-02-24" subject="utf_strlen"><description> </description></task><task budget="0:00:00" completiondate="2006-02-27" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1239662996:1140820920.45" lastModificationTime="2006-02-27 00:41:34.837031" priority="0" startdate="2006-02-24" subject="utf_strpos"><description> </description></task><task budget="0:00:00" completiondate="2006-02-27" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1239642132:1140820930.09" lastModificationTime="2006-02-27 00:41:47.022122" priority="0" startdate="2006-02-24" subject="utf8_strrpos"><description> </description></task><task budget="0:00:00" completiondate="2006-02-27" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1239607700:1140820976.4" lastModificationTime="2006-02-27 00:41:43.428199" priority="0" startdate="2006-02-24" subject="utf8_substr"><description> </description></task><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1255862228:1140997548.1" lastModificationTime="2006-02-27 00:45:54.876547" priority="0" startdate="2006-02-27" subject="Benchmark everything else"><description> </description></task></task><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1239564372:1140821061.38" lastModificationTime="2006-10-01 01:09:05.105057" priority="0" startdate="2006-02-24" subject="Tests"><description> </description><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1240007572:1140821079.0" lastModificationTime="2006-02-27 00:45:43.823337" priority="0" startdate="2006-02-24" subject="Add comparison tests to native str funcs where possible"><description>Comparisons of utf_* fns vs. the PHP str* functions for edge behaviour (e.g. sub_str with positions outside of string)</description></task></task><task budget="0:00:00" completiondate="2006-03-17" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1237832916:1140821382.46" lastModificationTime="2006-03-17 22:34:19.241813" priority="0" startdate="2006-02-24" subject="Packaging Helpers"><description> Add further ways to "build" library to reduce number of includes necessary
+
+- this is now partially mitigated by utf.php which works pretty well,
+
+Leaving as is</description></task><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1247868820:1140997369.86" lastModificationTime="2006-10-01 01:13:43.139144" priority="0" startdate="2006-02-27" subject="To Implement"><description> Stuff to add</description><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1249689556:1140997398.86" lastModificationTime="2006-02-27 00:43:24.018874" priority="0" startdate="2006-02-27" subject="wordwrap"><description> </description></task><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1249832788:1140997406.59" lastModificationTime="2006-02-27 00:44:50.945379" priority="0" startdate="2006-02-27" subject="byte index versions"><description>Where functions accept an integer character count as an argument, would be good to have byte index versions as well - can be useful in some instances where you're mingling with native str functions</description></task><task budget="0:00:00" completiondate="2006-03-17" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1252290516:1140997495.5" lastModificationTime="2006-03-17 22:33:51.394671" priority="0" startdate="2006-02-27" subject="romanise functionality from dokuwiki"><description> Add the "romanize" stuff
+
+Superceded by utf8 to ascii package</description></task><task budget="0:00:00" completiondate="2006-10-01" duedate="None" fixedFee="0.0" hourlyFee="0.0" id="-1244225460:1142631286.74" lastModificationTime="2006-10-01 01:09:48.366483" priority="0" startdate="2006-03-17" subject="utf8_ord"><description>UTF-8 char to ordinal </description></task><task budget="0:00:00" completiondate="None" duedate="None" fixedFee="0" hourlyFee="0" id="-1259147188:1159657799.21" lastModificationTime="2006-10-01 01:11:31.751804" priority="0" startdate="2006-10-01" subject="Alternative implementations of strtoupper / strtolower"><description>Potential faster implementations re. Marek Gayer approach described here
+
+http://www.sitepoint.com/blogs/2006/08/10/hot-php-utf-8-tips/ </description></task><task budget="0:00:00" completiondate="2006-10-01" duedate="None" fixedFee="0" hourlyFee="0" id="-1265549268:1159657987.36" lastModificationTime="2006-10-01 01:14:01.452465" priority="0" startdate="2006-10-01" subject="Convert UTF-8 char to byte given string"><description>Implement Chris Smith's solution
+
+Added to utils/position.php </description></task></task><task budget="0:00:00" completiondate="2006-10-01" duedate="None" fixedFee="0" hourlyFee="0" id="-1259119988:1159657905.89" lastModificationTime="2006-10-01 01:12:28.761774" priority="0" startdate="2006-10-01" subject="Bugs"><description> </description><task budget="0:00:00" completiondate="2006-10-01" duedate="None" fixedFee="0" hourlyFee="0" id="-1262108596:1159657912.48" lastModificationTime="2006-10-01 01:12:28.761710" priority="0" startdate="2006-10-01" subject="Bug 1547780"><description> http://sourceforge.net/tracker/index.php?func=detail&aid=1547780&group_id=142846&atid=753842
+
+</description></task></task></tasks>
\ No newline at end of file
--- /dev/null
+<?php
+header('content-type: text/html; charset=utf-8');
+
+# Require the main "loader" script...
+require_once '../../utf8.php';
+
+# UTF8 constant can now be used for directory
+# Follow functions automatically available;
+# utf8_strlen, utf8_strpos, utf8_strrpos, utf8_substr,
+# utf8_strtolower, utf8_strtoupper
+
+# A UTF-8 string...
+$str = 'Iñtërnâtiônàlizætiøn';
+
+print "String is: $str<br>\n";
+
+# Check it's a well formed UTF-8 string
+require_once UTF8 . '/utils/validation.php';
+if ( utf8_is_valid($str) ) {
+ print "It's well formed UTF-8<br>\n";
+} else {
+ print "It's badly formed UTF-8 - this shouldn't happen<br>\n";
+}
+
+print "Num chars: ".utf8_strlen($str)."<br>\n";
+
+print "Uppercase: ".utf8_strtoupper($str)."<br>\n";
+
+# Load an additional function;
+require_once UTF8 . '/strrev.php';
+
+print "Reversed: ".utf8_strrev($str)."<br>\n";
+?>
\ No newline at end of file
--- /dev/null
+<?php
+require_once(dirname(__FILE__).'/../../utils/unicode.php');
+
+function drawHashTable($hash, $lambdaX, $lambdaY) {
+ $o = '<table>';
+
+ $o .= '<tr>';
+ foreach ( range(1,10) as $i ) {
+ $o.="<th class=\"f\">From</th><th class=\"t\">To</th><th class=\"e\"></th>";
+ }
+ $o .= "</tr>\n";
+
+ $sep = '<tr>';
+ $j = 0;
+ foreach ( $hash as $k => $v ) {
+ if ( $j % 10 == 0 ) {
+ $j = 0;
+ $o.=$sep;
+ $sep = '</tr><tr>';
+ }
+ $o .= sprintf(
+ "<td class=\"f\">%s</td><td class=\"t\">%s</td><td class=\"e\"></td>",
+ $lambdaX($k),
+ $lambdaY($v)
+ );
+ $j++;
+ }
+
+ return $o . '</tr></table>';
+}
+
+function drawListTable ($list, $lambda) {
+ $o = '<table>';
+ $sep = '<tr>';
+ $j = 0;
+ foreach ( $list as $c ) {
+ if ( $j % 10 == 0 ) {
+ $j = 0;
+ $o.=$sep;
+ $sep = '</tr><tr>';
+ }
+ $o .= sprintf("<td>%s</td>",$lambda($c));
+ $j++;
+ }
+ return $o . '</tr></table>';
+}
+
+$chrtoutf8 = create_function('$c','return utf8_from_unicode(array($c));');
+$null = create_function('$c','return $c;');
+
+$UTF8_UPPER_TO_LOWER = array(
+ 0x0041=>0x0061, 0x03A6=>0x03C6, 0x0162=>0x0163, 0x00C5=>0x00E5, 0x0042=>0x0062,
+ 0x0139=>0x013A, 0x00C1=>0x00E1, 0x0141=>0x0142, 0x038E=>0x03CD, 0x0100=>0x0101,
+ 0x0490=>0x0491, 0x0394=>0x03B4, 0x015A=>0x015B, 0x0044=>0x0064, 0x0393=>0x03B3,
+ 0x00D4=>0x00F4, 0x042A=>0x044A, 0x0419=>0x0439, 0x0112=>0x0113, 0x041C=>0x043C,
+ 0x015E=>0x015F, 0x0143=>0x0144, 0x00CE=>0x00EE, 0x040E=>0x045E, 0x042F=>0x044F,
+ 0x039A=>0x03BA, 0x0154=>0x0155, 0x0049=>0x0069, 0x0053=>0x0073, 0x1E1E=>0x1E1F,
+ 0x0134=>0x0135, 0x0427=>0x0447, 0x03A0=>0x03C0, 0x0418=>0x0438, 0x00D3=>0x00F3,
+ 0x0420=>0x0440, 0x0404=>0x0454, 0x0415=>0x0435, 0x0429=>0x0449, 0x014A=>0x014B,
+ 0x0411=>0x0431, 0x0409=>0x0459, 0x1E02=>0x1E03, 0x00D6=>0x00F6, 0x00D9=>0x00F9,
+ 0x004E=>0x006E, 0x0401=>0x0451, 0x03A4=>0x03C4, 0x0423=>0x0443, 0x015C=>0x015D,
+ 0x0403=>0x0453, 0x03A8=>0x03C8, 0x0158=>0x0159, 0x0047=>0x0067, 0x00C4=>0x00E4,
+ 0x0386=>0x03AC, 0x0389=>0x03AE, 0x0166=>0x0167, 0x039E=>0x03BE, 0x0164=>0x0165,
+ 0x0116=>0x0117, 0x0108=>0x0109, 0x0056=>0x0076, 0x00DE=>0x00FE, 0x0156=>0x0157,
+ 0x00DA=>0x00FA, 0x1E60=>0x1E61, 0x1E82=>0x1E83, 0x00C2=>0x00E2, 0x0118=>0x0119,
+ 0x0145=>0x0146, 0x0050=>0x0070, 0x0150=>0x0151, 0x042E=>0x044E, 0x0128=>0x0129,
+ 0x03A7=>0x03C7, 0x013D=>0x013E, 0x0422=>0x0442, 0x005A=>0x007A, 0x0428=>0x0448,
+ 0x03A1=>0x03C1, 0x1E80=>0x1E81, 0x016C=>0x016D, 0x00D5=>0x00F5, 0x0055=>0x0075,
+ 0x0176=>0x0177, 0x00DC=>0x00FC, 0x1E56=>0x1E57, 0x03A3=>0x03C3, 0x041A=>0x043A,
+ 0x004D=>0x006D, 0x016A=>0x016B, 0x0170=>0x0171, 0x0424=>0x0444, 0x00CC=>0x00EC,
+ 0x0168=>0x0169, 0x039F=>0x03BF, 0x004B=>0x006B, 0x00D2=>0x00F2, 0x00C0=>0x00E0,
+ 0x0414=>0x0434, 0x03A9=>0x03C9, 0x1E6A=>0x1E6B, 0x00C3=>0x00E3, 0x042D=>0x044D,
+ 0x0416=>0x0436, 0x01A0=>0x01A1, 0x010C=>0x010D, 0x011C=>0x011D, 0x00D0=>0x00F0,
+ 0x013B=>0x013C, 0x040F=>0x045F, 0x040A=>0x045A, 0x00C8=>0x00E8, 0x03A5=>0x03C5,
+ 0x0046=>0x0066, 0x00DD=>0x00FD, 0x0043=>0x0063, 0x021A=>0x021B, 0x00CA=>0x00EA,
+ 0x0399=>0x03B9, 0x0179=>0x017A, 0x00CF=>0x00EF, 0x01AF=>0x01B0, 0x0045=>0x0065,
+ 0x039B=>0x03BB, 0x0398=>0x03B8, 0x039C=>0x03BC, 0x040C=>0x045C, 0x041F=>0x043F,
+ 0x042C=>0x044C, 0x00DE=>0x00FE, 0x00D0=>0x00F0, 0x1EF2=>0x1EF3, 0x0048=>0x0068,
+ 0x00CB=>0x00EB, 0x0110=>0x0111, 0x0413=>0x0433, 0x012E=>0x012F, 0x00C6=>0x00E6,
+ 0x0058=>0x0078, 0x0160=>0x0161, 0x016E=>0x016F, 0x0391=>0x03B1, 0x0407=>0x0457,
+ 0x0172=>0x0173, 0x0178=>0x00FF, 0x004F=>0x006F, 0x041B=>0x043B, 0x0395=>0x03B5,
+ 0x0425=>0x0445, 0x0120=>0x0121, 0x017D=>0x017E, 0x017B=>0x017C, 0x0396=>0x03B6,
+ 0x0392=>0x03B2, 0x0388=>0x03AD, 0x1E84=>0x1E85, 0x0174=>0x0175, 0x0051=>0x0071,
+ 0x0417=>0x0437, 0x1E0A=>0x1E0B, 0x0147=>0x0148, 0x0104=>0x0105, 0x0408=>0x0458,
+ 0x014C=>0x014D, 0x00CD=>0x00ED, 0x0059=>0x0079, 0x010A=>0x010B, 0x038F=>0x03CE,
+ 0x0052=>0x0072, 0x0410=>0x0430, 0x0405=>0x0455, 0x0402=>0x0452, 0x0126=>0x0127,
+ 0x0136=>0x0137, 0x012A=>0x012B, 0x038A=>0x03AF, 0x042B=>0x044B, 0x004C=>0x006C,
+ 0x0397=>0x03B7, 0x0124=>0x0125, 0x0218=>0x0219, 0x00DB=>0x00FB, 0x011E=>0x011F,
+ 0x041E=>0x043E, 0x1E40=>0x1E41, 0x039D=>0x03BD, 0x0106=>0x0107, 0x03AB=>0x03CB,
+ 0x0426=>0x0446, 0x00DE=>0x00FE, 0x00C7=>0x00E7, 0x03AA=>0x03CA, 0x0421=>0x0441,
+ 0x0412=>0x0432, 0x010E=>0x010F, 0x00D8=>0x00F8, 0x0057=>0x0077, 0x011A=>0x011B,
+ 0x0054=>0x0074, 0x004A=>0x006A, 0x040B=>0x045B, 0x0406=>0x0456, 0x0102=>0x0103,
+ 0x039B=>0x03BB, 0x00D1=>0x00F1, 0x041D=>0x043D, 0x038C=>0x03CC, 0x00C9=>0x00E9,
+ 0x00D0=>0x00F0, 0x0407=>0x0457, 0x0122=>0x0123,
+ );
+
+$UTF8_LOWER_TO_UPPER = array(
+ 0x0061=>0x0041, 0x03C6=>0x03A6, 0x0163=>0x0162, 0x00E5=>0x00C5, 0x0062=>0x0042,
+ 0x013A=>0x0139, 0x00E1=>0x00C1, 0x0142=>0x0141, 0x03CD=>0x038E, 0x0101=>0x0100,
+ 0x0491=>0x0490, 0x03B4=>0x0394, 0x015B=>0x015A, 0x0064=>0x0044, 0x03B3=>0x0393,
+ 0x00F4=>0x00D4, 0x044A=>0x042A, 0x0439=>0x0419, 0x0113=>0x0112, 0x043C=>0x041C,
+ 0x015F=>0x015E, 0x0144=>0x0143, 0x00EE=>0x00CE, 0x045E=>0x040E, 0x044F=>0x042F,
+ 0x03BA=>0x039A, 0x0155=>0x0154, 0x0069=>0x0049, 0x0073=>0x0053, 0x1E1F=>0x1E1E,
+ 0x0135=>0x0134, 0x0447=>0x0427, 0x03C0=>0x03A0, 0x0438=>0x0418, 0x00F3=>0x00D3,
+ 0x0440=>0x0420, 0x0454=>0x0404, 0x0435=>0x0415, 0x0449=>0x0429, 0x014B=>0x014A,
+ 0x0431=>0x0411, 0x0459=>0x0409, 0x1E03=>0x1E02, 0x00F6=>0x00D6, 0x00F9=>0x00D9,
+ 0x006E=>0x004E, 0x0451=>0x0401, 0x03C4=>0x03A4, 0x0443=>0x0423, 0x015D=>0x015C,
+ 0x0453=>0x0403, 0x03C8=>0x03A8, 0x0159=>0x0158, 0x0067=>0x0047, 0x00E4=>0x00C4,
+ 0x03AC=>0x0386, 0x03AE=>0x0389, 0x0167=>0x0166, 0x03BE=>0x039E, 0x0165=>0x0164,
+ 0x0117=>0x0116, 0x0109=>0x0108, 0x0076=>0x0056, 0x00FE=>0x00DE, 0x0157=>0x0156,
+ 0x00FA=>0x00DA, 0x1E61=>0x1E60, 0x1E83=>0x1E82, 0x00E2=>0x00C2, 0x0119=>0x0118,
+ 0x0146=>0x0145, 0x0070=>0x0050, 0x0151=>0x0150, 0x044E=>0x042E, 0x0129=>0x0128,
+ 0x03C7=>0x03A7, 0x013E=>0x013D, 0x0442=>0x0422, 0x007A=>0x005A, 0x0448=>0x0428,
+ 0x03C1=>0x03A1, 0x1E81=>0x1E80, 0x016D=>0x016C, 0x00F5=>0x00D5, 0x0075=>0x0055,
+ 0x0177=>0x0176, 0x00FC=>0x00DC, 0x1E57=>0x1E56, 0x03C3=>0x03A3, 0x043A=>0x041A,
+ 0x006D=>0x004D, 0x016B=>0x016A, 0x0171=>0x0170, 0x0444=>0x0424, 0x00EC=>0x00CC,
+ 0x0169=>0x0168, 0x03BF=>0x039F, 0x006B=>0x004B, 0x00F2=>0x00D2, 0x00E0=>0x00C0,
+ 0x0434=>0x0414, 0x03C9=>0x03A9, 0x1E6B=>0x1E6A, 0x00E3=>0x00C3, 0x044D=>0x042D,
+ 0x0436=>0x0416, 0x01A1=>0x01A0, 0x010D=>0x010C, 0x011D=>0x011C, 0x00F0=>0x00D0,
+ 0x013C=>0x013B, 0x045F=>0x040F, 0x045A=>0x040A, 0x00E8=>0x00C8, 0x03C5=>0x03A5,
+ 0x0066=>0x0046, 0x00FD=>0x00DD, 0x0063=>0x0043, 0x021B=>0x021A, 0x00EA=>0x00CA,
+ 0x03B9=>0x0399, 0x017A=>0x0179, 0x00EF=>0x00CF, 0x01B0=>0x01AF, 0x0065=>0x0045,
+ 0x03BB=>0x039B, 0x03B8=>0x0398, 0x03BC=>0x039C, 0x045C=>0x040C, 0x043F=>0x041F,
+ 0x044C=>0x042C, 0x00FE=>0x00DE, 0x00F0=>0x00D0, 0x1EF3=>0x1EF2, 0x0068=>0x0048,
+ 0x00EB=>0x00CB, 0x0111=>0x0110, 0x0433=>0x0413, 0x012F=>0x012E, 0x00E6=>0x00C6,
+ 0x0078=>0x0058, 0x0161=>0x0160, 0x016F=>0x016E, 0x03B1=>0x0391, 0x0457=>0x0407,
+ 0x0173=>0x0172, 0x00FF=>0x0178, 0x006F=>0x004F, 0x043B=>0x041B, 0x03B5=>0x0395,
+ 0x0445=>0x0425, 0x0121=>0x0120, 0x017E=>0x017D, 0x017C=>0x017B, 0x03B6=>0x0396,
+ 0x03B2=>0x0392, 0x03AD=>0x0388, 0x1E85=>0x1E84, 0x0175=>0x0174, 0x0071=>0x0051,
+ 0x0437=>0x0417, 0x1E0B=>0x1E0A, 0x0148=>0x0147, 0x0105=>0x0104, 0x0458=>0x0408,
+ 0x014D=>0x014C, 0x00ED=>0x00CD, 0x0079=>0x0059, 0x010B=>0x010A, 0x03CE=>0x038F,
+ 0x0072=>0x0052, 0x0430=>0x0410, 0x0455=>0x0405, 0x0452=>0x0402, 0x0127=>0x0126,
+ 0x0137=>0x0136, 0x012B=>0x012A, 0x03AF=>0x038A, 0x044B=>0x042B, 0x006C=>0x004C,
+ 0x03B7=>0x0397, 0x0125=>0x0124, 0x0219=>0x0218, 0x00FB=>0x00DB, 0x011F=>0x011E,
+ 0x043E=>0x041E, 0x1E41=>0x1E40, 0x03BD=>0x039D, 0x0107=>0x0106, 0x03CB=>0x03AB,
+ 0x0446=>0x0426, 0x00FE=>0x00DE, 0x00E7=>0x00C7, 0x03CA=>0x03AA, 0x0441=>0x0421,
+ 0x0432=>0x0412, 0x010F=>0x010E, 0x00F8=>0x00D8, 0x0077=>0x0057, 0x011B=>0x011A,
+ 0x0074=>0x0054, 0x006A=>0x004A, 0x045B=>0x040B, 0x0456=>0x0406, 0x0103=>0x0102,
+ 0x03BB=>0x039B, 0x00F1=>0x00D1, 0x043D=>0x041D, 0x03CC=>0x038C, 0x00E9=>0x00C9,
+ 0x00F0=>0x00D0, 0x0457=>0x0407, 0x0123=>0x0122,
+ );
+
+$UTF8_UPPER_ACCENTS = array(
+ 'À' => 'A', 'Ô' => 'O', 'Ď' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Š' => 'S', 'Ơ' => 'O',
+ 'Ă' => 'A', 'Ř' => 'R', 'Ț' => 'T', 'Ň' => 'N', 'Ā' => 'A', 'Ķ' => 'K',
+ 'Ŝ' => 'S', 'Ỳ' => 'Y', 'Ņ' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'Ṗ' => 'P', 'Ó' => 'O',
+ 'Ú' => 'U', 'Ě' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'Ċ' => 'C', 'Õ' => 'O',
+ 'Ṡ' => 'S', 'Ø' => 'O', 'Ģ' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ė' => 'E', 'Ĉ' => 'C',
+ 'Ś' => 'S', 'Î' => 'I', 'Ű' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Ŵ' => 'W', 'Ṫ' => 'T',
+ 'Ū' => 'U', 'Č' => 'C', 'Ö' => 'Oe', 'È' => 'E', 'Ŷ' => 'Y', 'Ą' => 'A', 'Ł' => 'L',
+ 'Ų' => 'U', 'Ů' => 'U', 'Ş' => 'S', 'Ğ' => 'G', 'Ļ' => 'L', 'Ƒ' => 'F', 'Ž' => 'Z',
+ 'Ẃ' => 'W', 'Ḃ' => 'B', 'Å' => 'A', 'Ì' => 'I', 'Ï' => 'I', 'Ḋ' => 'D', 'Ť' => 'T',
+ 'Ŗ' => 'R', 'Ä' => 'Ae', 'Í' => 'I', 'Ŕ' => 'R', 'Ê' => 'E', 'Ü' => 'Ue', 'Ò' => 'O',
+ 'Ē' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Ĝ' => 'G', 'Đ' => 'D', 'Ĵ' => 'J',
+ 'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Ţ' => 'T', 'Ý' => 'Y', 'Ő' => 'O',
+ 'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Ż' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ġ' => 'G',
+ 'Ṁ' => 'M', 'Ō' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Į' => 'I', 'Ź' => 'Z', 'Á' => 'A',
+ 'Û' => 'U', 'Þ' => 'Th', 'Ð' => 'Dh', 'Æ' => 'Ae', 'Ĕ' => 'E',
+ );
+
+$UTF8_LOWER_ACCENTS = array(
+ 'à' => 'a', 'ô' => 'o', 'ď' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'š' => 's', 'ơ' => 'o',
+ 'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k',
+ 'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o',
+ 'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o',
+ 'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c',
+ 'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't',
+ 'ū' => 'u', 'č' => 'c', 'ö' => 'oe', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l',
+ 'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z',
+ 'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't',
+ 'ŗ' => 'r', 'ä' => 'ae', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o',
+ 'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j',
+ 'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o',
+ 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g',
+ 'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a',
+ 'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', 'ĕ' => 'e',
+ );
+
+header('Content-Type: text/html; charset=utf-8');
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
+lang="en" dir="ltr">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>PHP-UTF8 Lookup Tables</title>
+<style type="text/css">
+<!--
+body,div,p,blockquote,ol,ul,dl,li,dt,dd,td,th {
+ font-family: arial,helvetica,sans-serif
+}
+td {
+ border: none;
+ padding: none;
+ width: 40px;
+ text-align: center;
+}
+.f {
+ background-color: #458B00;
+}
+.t {
+ background-color: #D2691E;
+}
+
+-->
+</style>
+</head>
+<body>
+<h1>PHP-UTF8 Lookup Tables</h1>
+<p>Shows you the some of the lookup tables PHP-UTF8 uses (there's also a .</p>
+<ul>
+<li><a href="#utf8_strtolower">utf8_strtolower</a></li>
+<li><a href="#utf8_strtoupper">utf8_strtoupper</a></li>
+<li><a href="#utf8_upper_accents">utf8_upper_accents</a></li>
+<li><a href="#utf8_lower_accents">utf8_lower_accents</a></li>
+</ul>
+
+<a name="utf8_strtolower"></a>
+<h2>Upper Case to Lower Case (utf8_strtolower)</h2>
+<?php echo drawHashTable($UTF8_UPPER_TO_LOWER, $chrtoutf8, $chrtoutf8 ); ?>
+
+<a name="utf8_strtoupper"></a>
+<h2>Lower Case to Upper Case (utf8_strtoupper)</h2>
+<?php echo drawHashTable($UTF8_LOWER_TO_UPPER, $chrtoutf8, $chrtoutf8 ); ?>
+
+<a name="utf8_upper_accents"></a>
+<h2>Upper Case Accented Characters (replaced by utf8_accents_to_ascii())</h2>
+<p>Note for a more complete implementation of UTF-8 to ASCII character replacement,
+see the <a href="http://prdownloads.sourceforge.net/phputf8">utf8_to_ascii</a> package.</p>
+<?php echo drawHashTable($UTF8_UPPER_ACCENTS, $null, $null); ?>
+
+<a name="utf8_lower_accents"></a>
+<h2>Lower Case Accented Characters (replaced by utf8_accents_to_ascii())</h2>
+<p>Note for a more complete implementation of UTF-8 to ASCII character replacement,
+see the <a href="http://prdownloads.sourceforge.net/phputf8">utf8_to_ascii</a> package.</p>
+<?php echo drawHashTable($UTF8_LOWER_ACCENTS, $null, $null); ?>
+
+</body>
+</html>
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use Pod::Xhtml;
+use File::Basename;
+
+my $filename = 'phputf8.pod';
+
+my $basename = basename($filename);
+$basename =~ s/.[a-z]{3}$//;
+
+
+my $POD = Pod::Xhtml->new();
+
+$POD->addHeadText('<meta http-equiv="Content-Type"
+ content="text/html; charset=UTF-8" />');
+$POD->addHeadText('<link rel="stylesheet" media="screen" type="text/css" href="screen.css" />');
+$POD->addHeadText('<link rel="stylesheet" media="print" type="text/css" href="print.css" />');
+$POD->addBodyOpenText('<div id="header">');
+$POD->addBodyOpenText('<h1 class="title">'.$basename.'</h1>');
+$POD->addBodyOpenText('</div>');
+$POD->addBodyOpenText('<div id="nav">');
+$POD->addBodyOpenText('[ <a href="http://phputf8.sourceforge.net/api/">API docs</a> ]');
+$POD->addBodyOpenText('</div>');
+
+$POD->parse_from_file('phputf8.pod');
+
--- /dev/null
+# $Id: phputf8.pod,v 1.7 2006/09/30 23:38:19 harryf Exp $
+
+=head1 NAME
+
+phputf8 - Tools for working with UTF-8 in PHP
+
+=head1 SYNOPSIS
+
+ require_once '/path/to/utf8/utf8.php';
+ require_once UTF8 . '/utils/validation.php';
+ require_once UTF8 . '/utils/ascii.php';
+
+ # Check the UTF-8 is well formed
+ if ( !utf8_is_valid($_POST['somecontent']) ) {
+
+ require_once UTF8 . '/utils/bad.php';
+ trigger_error('Bad UTF-8 detected. Clearning', E_USER_NOTICE);
+
+ # Strip out bad sequences - replace with ? character
+ $_POST['somecontent'] = utf8_bad_replace($_POST['somecontent']);
+
+ }
+
+ # This works fine with UTF-8
+ $_POST['somecontent'] = ltrim($_POST['somecontent']);
+
+ # If it contains only ascii chars, use native str fns for speed...
+ if ( !utf8_is_ascii($_POST['somecontent']) ) {
+
+ $endfirstword = strpos($_POST['somecontent'],' ');
+ $firstword = substr($_POST['somecontent'],0,$endOfFirstWord);
+ $firstword = strtoupper($firstword);
+ $therest = substr($_POST['somecontent'],$endOfFirstWord);
+
+ } else {
+
+ # It contains multibyte sequences - use the slower but safe
+ $endfirstword = utf8_strpos($_POST['somecontent'],' ');
+ $firstword = utf8_substr($_POST['somecontent'],0,$endOfFirstWord);
+ $firstword = utf8_strtoupper($firstword);
+ $therest = utf8_substr($_POST['somecontent'],$endOfFirstWord);
+
+ }
+
+ # htmlspecialchars is also safe for use with UTF-8
+ header("Content-Type: text/html; charset=utf-8");
+ echo "<pre>";
+ echo "<strong>".htmlspecialchars($firstword)."</strong>";
+ echo htmlspecialchars($therest);
+ echo "</pre>";
+
+
+=head1 DESCRIPTION
+
+phputf8 does a few things for you;
+
+=over
+
+=item * Provides UTF-8 aware versions of PHP's string functions
+
+All of these functions are prefixed with C<utf8_>. Six of these functions
+are loaded "on the fly", depending on whether you have the mbstring
+extension available. The rest build on top of those six.
+
+See L</"String Functions">.
+
+=item * Detection of bad UTF-8 sequences
+
+The file C<UTF8 . '/utils/validation.php'> contains functions for testing
+strings for bad UTF-8 sequences. Note that other functions in the library
+assume valid UTF-8.
+
+See L</"UTF-8 Validation and Cleaning">
+
+=item * Cleaning of bad UTF-8 sequences
+
+Functions for stripping or replacing bad sequences are available in
+C<UTF8 . '/utils/bad.php'>
+
+See L</"UTF-8 Validation and Cleaning">
+
+=item * Detecting pure ASCII & stripping non-ASCII
+
+The file C<UTF8 . '/utils/ascii.php'> contains utilities to detect
+whether a UTF-8 string contains just ASCII characters (allowing
+you to use PHP's faster, native, string functions) and also stripping
+everything non-ASCII from a string
+
+See L</"Performance and Optimization">
+
+=item * Basic transliteration
+
+The file C<UTF8 . '/utils/specials.php'> contains basic transliteration
+functionality (L<http://en.wikipedia.org/wiki/Transliteration>) - not
+much but enough to convert common European, non-ascii characters to
+a reasonable ASCII equivalent. You might use these when preparing a
+string for use as a filename, afterwhich you strip all other non-ascii
+characters using the ASCII utilities.
+
+Further transliteration is provided in the C<utf8_to_ascii> package
+at L<http://sourceforge.net/projects/phputf8>. Much more powerful
+functionality is provided by the pecl transliteration extension -
+L<http://derickrethans.nl/translit.php> and
+L<http://pecl.php.net/package/translit>.
+
+See L</"Transliteration">
+
+=back
+
+=head1 String Functions
+
+There are seven essential functions provided by phputf8, which are
+required by many of the other functions. These are all loaded
+when you include the main C<utf8.php> script e.g.
+
+ require_once '/path/to/utf8/utf8.php';
+
+Six of these functions depend on whether the mbstring extension is
+installed (see L<http://www.php.net/mbstring>) - if it is available,
+the following functions will be wrappers around the equivalent
+mb_string functions;
+
+=over
+
+=item * C<utf8_strlen>
+
+=item * C<utf8_strpos>
+
+=item * C<utf8_strrpos>
+
+=item * C<utf8_substr>
+
+=item * C<utf8_strtolower>
+
+=item * C<utf8_strtoupper>
+
+=back
+
+B<Note:> phputf8 cannot support mbstring function overloading;
+it relies in some cases on PHP's native string functions
+counting characters as bytes.
+
+The seventh function is C<utf8_substr_replace>, which is
+implemented independent of mbstring (mbstring doesn't
+provide it).
+
+B<Important Note> - if you do not load C<utf8.php> and you wish
+to use the mbstring implementations, you need to set the mbstring
+encoding to UTF-8 yourself - see L<http://www.php.net/mb_internal_encoding>.
+
+=head2 Further string functions
+
+All other string functions must be included on demand. They are
+available directly under the C<UTF8> directory with filenames
+corresponding to the equivalent PHP string functions, but still
+with the function prefix C<utf8_>.
+
+For example, to load the strrev implementation;
+
+ # Load the main script
+ require_once '/path/to/utf8/utf8.php';
+
+ # Load the UTF-8 aware strrev implementation
+ require_once UTF8 . '/strrev.php';
+ print utf8_strrev('Iñtërnâtiônàlizætiøn')."\n";
+
+All string implementations are found in the C<UTF8> directory.
+For documentation for each function, see the phpdocs
+L<http://phputf8.sourceforge.net/api>.
+
+B<TODO> Some of the functions, such as C<utf8_strcspn> take
+arguments like 'start' and 'length', requiring values in terms
+of I<characters> not bytes - i.e. return values from functions
+like C<utf8_strlen> and C<utf8_strpos>. Additional implementations
+would be useful which take byte indexes instead of character
+positions - this would allow further advantage to be taken of
+UTF-8's design and more use of PHP's native functions for performance.
+
+=head1 UTF-8 Validation and Cleaning
+
+It's important to understand that multi-byte UTF-8 characters can be
+badly formed. UTF-8 has rules regarding multi-byte characters and those
+rules can be broken. Some possible reasons why a sequence of bytes
+might be badly formed UTF-8;
+
+=over
+
+=item It's a different character encoding
+
+For example, 8 bit characters in ISO-8859-1 would be badly formed UTF-8.
+That said, characters declared as ISO-8859-1 but still within the ASCII-7
+range would still be valid UTF-8.
+
+=item It's a corrupted UTF-8 string
+
+Something has mangled the UTF-8 string (PHP's native strrev function,
+for example, would do this).
+
+=item Someone is injecting badly formed UTF-8 input deliberately.
+
+They might be attempting to "break" you RSS feed, for example.
+
+=back
+
+With that in mind, the functions provided in C<./utils/validation.php>
+and C<./utils/bad.php> are intend to help guard against such problems.
+
+=head2 Validation
+
+There are two functions in C<./utils/validation.php>, one "strict"
+and the other slightly more relaxed.
+
+The strict version is C<utf8_is_valid> - as well is checking each
+sequence, byte-by-byte, it also regards sequences which are not
+part of the Unicode standard as being invalid (UTF-8 allows for
+5 and 6 byte sequences but have no meaning in Unicode, and will
+result in browsers displaying "junk" characters (e.g. ? character).
+
+The second function C<utf8_compliant> relies of behaviour of
+PHP's PCRE extension, to spot invalid UTF-8 sequences. This
+function will pass 5 and 6 byte sequences but also performs
+much better than C<utf8_is_valid>.
+
+Both are simple to use;
+
+ require_once UTF8 . '/utils/validation.php';
+ if ( utf8_is_valid($str) ) {
+ print "Its valid\n";
+ }
+ if ( utf8_is_compliant($str) ) {
+ print "Its compliant\n";
+ }
+
+
+=head2 Cleaning UTF-8
+
+If you detect a UTF-8 encoded string contains badly formed
+sequences, functions in C<./utils/bad.php> can help. Be warned
+that performance on large strings will be an issue.
+
+It provides the following functitons;
+
+=over
+
+=item * C<utf8_bad_find>
+
+Locates the I<first> bad byte in a UTF-8 string, returning it's
+I<byte> (not chacacter) position in the string. You might use this
+for iterative cleaning or analysis of a UTF-8 string for example;
+
+ require_once UTF8 . '/utils/validation.php';
+ require_once UTF8 . '/utils/bad.php';
+
+ $clean = '';
+ while ( FALSE !== ( $badIndex = utf8_bad_find($str) ) ) {
+ print "Bad byte found at $badIndex\n";
+ $clean .= substr($str,0,$badIndex);
+ $str = substr($str,$badIndex+1);
+ }
+ $clean .= $str;
+
+=item * C<utf8_bad_findall>
+
+The same as C<utf8_bad_find> but searches the complete string and
+returns the index of all bad bytes found in an array
+
+=item * C<utf8_bad_strip>
+
+Removes all bad bytes from a UTF-8 string, returning the cleaned string
+
+=item * C<utf8_bad_replace>
+
+Removes all bad bytes from a UTF-8 string and replaces them with some
+other character (default is ?)
+
+=item * C<utf8_bad_identify> and C<utf8_bad_explain>
+
+Together these two functions attempt to provide a reason why a
+particular byte is not valid UTF-8. Perhaps you might use these
+when logging errors.
+
+=back
+
+=head2 Warning on ASCII Control Characters
+
+The above functions for validating and cleaning UTF-8 strings
+all regard ASCII control characters as being valid and
+acceptable. But ASCII control chars are not acceptable in XML
+documents - use the C<utf8_strip_ascii_ctrl> function in
+C<./utils/ascii.php> (available v0.3+), which will remove
+all ASCII control characters that are illegal in XML.
+
+See L<http://hsivonen.iki.fi/producing-xml/#controlchar>.
+
+=head2 Strategy
+
+Because validation and cleaning UTF-8 strings comes with a pretty high
+cost, in terms of performance, you should be aiming to do this once
+only, at the point where you receive some input (e.g. a submitted form)
+before going on to using the rest of the string functions in this library.
+
+You should also be aware that validation and cleaning is your job -
+the utf8_* string functions I<assume> they are being given well formed
+UTF-8 to process, because the performance overhead of checking, every
+time you called C<utf8_strlen>, for example, would be very high.
+
+=head1 Performance and Optimization
+
+The first thing you I<shouldn't> be attempting to do is replace all use of PHP's
+native string functions with functions from this library. Doing so will have
+a dramatic (and bad) effect on your codes performance. It also misses opportunities
+you may have to continue using PHP's native string functions.
+
+There are two main areas to consider, when working out how to support UTF-8
+with this library and achieve optimal performance.
+
+=head2 When data is 99% ASCII
+
+First, if the majority of the data your application will be processing is
+written in English, most of the time you will be able to use PHP's native
+string functions, only using the utf8_* string functions when you encounter
+multibyte characters. This has already been implied above in the example
+in the L</"SYNOPSIS">. Most characters used in English fall within the
+ASCII-7 range and ASCII characters in UTF-8 are no different to normal
+ASCII characters.
+
+So check whether a string is 100% ASCII first, and if so, use PHP's native
+string functions on it.
+
+ require_once '/path/to/utf8/utf8.php';
+ require_once UTF8 . '/utils/ascii.php';
+
+ if ( utf8_is_ascii($string) ) {
+ # use native PHP string functions
+ } else {
+ # use utf8_* string functions
+ }
+
+=head2 Exploiting UTF-8's design
+
+Second, you may be able to exploit UTF-8's design to your advantage,
+depending on what I<exactly> you are doing to a string. This road
+requires more effort and a good understanding of UTF-8's design.
+
+As a starting point, you really need to examine the range table
+shown on Wikipedias page on UTF-8 L<http://en.wikipedia.org/wiki/UTF-8>.
+
+Some key points about UTF-8's design;
+
+=over
+
+=item UTF-8 is a superset of ASCII
+
+In other words ASCII-7 characters are encoded in exactly the same
+way as normal. These characters are those shown of the I<first>
+table L<http://www.lookuptables.com/> - the first 128 characters.
+
+Note that the second table shown at L<http://www.lookuptables.com/>
+"Extended ASCII characters" are not ASCII-7 characters are I<are>
+encoded differently in UTF-8 (probably using 2 bytes). Those
+characters seem to be ISO-8859-1 - occasionally you will seen
+people saying UTF-8 is backwards compatible with ISO-8859-1 - this
+is I<wrong>.
+
+One specific example which illustrates this;
+
+ $new_utf8_str = strstr('Iñtërnâtiônàlizætiøn','l');
+
+Using the "needle" character 'l' (in the ASCII-7 range), this
+example works without any problems, the variable C<$new_utf8_str>
+being assigned the value 'lizætiøn', even though the haystack
+string contains multibyte characters.
+
+Actually this example leads into the next point...
+
+=item Every character sequence is unique in UTF-8
+
+Assuming that a UTF-8 encoded string is well formed, any sequence
+in that string representing a single character (be it a single
+byte ASCII character or a multi byte character) cannot be mistaken
+is as a subsequence of a larger multi byte sequence.
+
+That means all of the following examples work;
+
+ # Pop off a piece of a string using multi-byte character
+ $new_utf8_str = strstr('Iñtërnâtiônàlizætiøn','ô');
+
+ # Explode string using multibyte character
+ $array = explode('ô','Iñtërnâtiônàlizætiøn');
+
+ # Using byte index instead of chacter index...
+ $haystack = 'Iñtërnâtiônàlizætiøn';
+ $needle = 'ô';
+ $pos = strpos($haystack, $needle);
+ print "Position in bytes is $pos<br>";
+ $substr = substr($haystack, 0, $pos);
+ print "Substr: $substr<br>";
+
+
+=back
+
+Put those together and often you will be able to use existing code
+with little or no modification.
+
+Often you will be able to continue working in bytes instead of
+logical characters (as the last example above shows).
+
+There are some functions which you I<will> always need to replace,
+for example C<strtoupper>. You should be able to get some idea of
+which these functions are by looking at
+L<http://www.phpwact.org/php/i18n/utf-8>.
+
+
+=head1 Transliteration
+
+Sometimes you will need to be able to remove all multi-byte
+characters from a UTF-8 string and use only ASCII. Some
+possible reasons why;
+
+=over
+
+=item Interfaces to systems with no support for UTF-8
+
+An application might be accessing data from your application
+but lack support for UTF-8. You may need to remove all non-
+ASCII-7 characters for it.
+
+=item Filenames
+
+Although most modern operating systems support Unicode, not
+all applications running under that OS may do so and you may
+be exposing yourself to security issues by allowing multi
+byte characters in filenames.
+
+=item Urls
+
+Similar issues to filenames - most modern browsers support
+the use of UTF-8 in URLs but doing so may not be a smart
+idea e.g. potential for phishing via the use of similar
+looking (to humans) characters.
+
+=item Primary Keys / Identifiers
+
+It is probably unwise to allow multi-byte UTF-8 characters into
+certain critical "fields" in your application, such as a username.
+Someone might be able to register a user with a similar looking
+name to an admin user - consider "admin" vs. "admın" < hard to
+spot the difference (note the ı character in the second example).
+
+=back
+
+=head2 Stripping multi byte characters
+
+To simply remove all multibyte characters, the C<./utils/ascii.php>
+collection of functions can help e.g.;
+
+ require_once '/path/to/utf8/utf8.php';
+ require_once UTF8 . '/utils/ascii.php';
+ $str = "admın";
+ print utf8_strip_non_ascii($str); // prints "admn"
+
+Not also the C<utf8_strip_non_ascii_ctrl> function which also -
+strips out ASCII control codes - see
+L</"Warning on ASCII Control Characters"> for information on that
+topic.
+
+=head2 Transliteration Utilities
+
+Now simply throwing out characters is not kind to users. An
+alternative is transliteration, where you try to replace multi
+byte characters with equivalent ASCII characters that a human
+would understand. For example "Zürich" could be converted to
+"Zuerich", the multi byte "ü" character being replaced by "ue".
+
+See L<http://en.wikipedia.org/wiki/Transliteration> for a
+general introduction to transliteration.
+
+The main phputf8 package contains a single function in
+the C<./utils/ascii.php> script that does some (basic)
+replacements of accented characters common in languages
+like French. After using this function, you should still
+strip out all remaining multi-byte characters. For
+example;
+
+ require_once '/path/to/utf8/utf8.php';
+ require_once UTF8 . '/utils/ascii.php';
+
+ $filename = utf8_accents_to_ascii($filename);
+ $filename = utf8_strip_non_ascii($filename);
+
+This will at least preserve I<some> characters in an
+ASCII form that will be understandable by users.
+
+Further an much more powerful transliteration
+capabilities are provided in the seperate utf8_to_ascii
+package distributed at L<http://sourceforge.net/projects/phputf8>.
+Because it is a port of Perls' L<Text::Unidecode> package
+to PHP, it is distruted under the same license.
+
+A quick intro to utf8_to_ascii and be found at
+L<http://www.sitepoint.com/blogs/2006/03/03/us-ascii-transliterations-of-unicode-text/>
+
+Be warned that utf8_to_ascii does have limitations and a better
+choice, if you have rights to install it in your environemt, is
+Derick Rethans transliteration extension:
+L<http://pecl.php.net/package/translit>.
+
+
+=head1 SEE ALSO
+
+L<http://www.phpwact.org/php/i18n/charsets>,
+L<http://www.phpwact.org/php/i18n/utf-8>
+L<http://wiki.silverorange.com/UTF-8_Notes>
+L<http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/normal/> - Unicode normalization in PHP
+L<http://www.webtuesday.ch/_media/meetings/utf-8_survival.pdf>
--- /dev/null
+body {
+ font: 10pt "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif;
+ background-color: White;
+ color: Black;
+}
+table {
+ font-size: 100%;
+ padding:0;
+ margin:0;
+}
+tr,td,th {padding:0; margin:0;}
+img {border:0}
+a {
+ color:#000000;
+ text-decoration:none;
+}
+pod.page {
+ text-align: justify;
+}
+h1, h2, h3, h4, h5 {
+ color: Black;
+ background-color: transparent;
+ font-family: "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif;
+ font-size: 100%;
+ font-weight: normal;
+ margin-left: 0;
+ margin-right: 0;
+ margin-top: 0;
+ margin-bottom: 1em;
+ padding-left: 0;
+ padding-right: 0;
+ padding-top: 0.5em;
+ padding-bottom: 0;
+ border-bottom: 1px solid #000000;
+ clear:left;
+}
+h1 {font-size: 160%; font-weight: bold;}
+h2 {font-size: 150%; }
+h3 {font-size: 140%; border-bottom: none; }
+h4 {font-size: 120%; border-bottom: none; }
+h5 {font-size: 100%; border-bottom: none; }
+ul {
+ line-height: 1.5em;
+ list-style-type: square;
+ margin: 0 0 1.0em 1.5em;
+ padding: 0;
+
+}
+ol {
+ line-height: 1.0em;
+ margin: 0 0 1.0em 1.0em;
+ padding: 0;
+ font-weight: normal;
+}
+
+pre {
+ font-size: 8pt;
+ padding: 0.5em;
+ border: 1px dashed #000000;
+ color: Black;
+ overflow: visible;
+ font-family: "Courier New",Courier,monospace;
+}
+code {
+ font-family: "Courier New",Courier,monospace;
+}
+.toplink {display:none}
+#nav {display:none}
--- /dev/null
+/*
+* Adapted from http://resources.neolao.com/php/dokuwiki/templates
+*/
+* {
+ font-family: Verdana, Helvetica, Arial, sans-serif;
+ font-size: small;
+}
+body {
+ background: white;
+}
+a { text-decoration: none; color: #5d579d; }
+a:hover { color: #827db7; }
+h1 {
+ color: #f4a600;
+ font-size: 1.5em;
+}
+h1.title {
+ background-color: #fffff5;
+ font-size: 2.0em;
+}
+h2 {
+ color: #f4a600;
+ font-size: 1.2em;
+}
+h3 {
+ color: #817cb6;
+ font-size: 1em;
+}
+h4 {
+ color: #817cb6;
+ font-size: 1em;
+}
+h5 {
+ color: #817cb6;
+ font-size: 1em;
+}
+table { border: solid 1px #999; }
+table th { border: solid 1px #999; background-color: #eee; }
+table td { border: solid 1px #ccc; background-color: #fff; }
+table tr:hover { background-color: #ffffe5; }
+blockquote { border-left: solid 2px #a58fbb; margin: 0; padding: 0 0 0 .5em; }
+p { margin: .5em 0 0 0; }
+pre {
+ padding: 2px;
+ border: 1px dotted #8cacbb;
+ color: #000;
+ overflow: auto;
+ background-color: #fffff5; font-size: 1em; font-family: "Courier New",Courier,monospace;
+}
+pre * { background-color: #fffff5; font-size: 1em; font-family: "Courier New",Courier,monospace; }
+code { background-color: #fffff5; border: 1px dotted #8cacbb; font-size: 1em; font-family: "Courier New",Courier,monospace; }
+
--- /dev/null
+<?php
+/**
+* This was an experiment to see how a PCRE based UTF-8 to unicode
+* code point converter would perform, vs. a character by character
+* converted (as in '../utf8_unicode.php'). Basically this is very
+* by comparion but perhaps interesting code anyway
+*/
+$UTF8_MATCH =
+ '([\x09\x0A\x0D\x20-\x7E])'. # ASCII (excluding control chars)
+ '|([\xC2-\xDF][\x80-\xBF]'. # non-overlong 2-byte
+ '|\xE0[\xA0-\xBF][\x80-\xBF])'. # excluding overlongs
+ '|([\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte
+ '|\xED[\x80-\x9F][\x80-\xBF]'. # excluding surrogates
+ '|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3
+ '|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15
+ '|\xF4[\x80-\x8F][\x80-\xBF]{2})'; # plane 16
+ '|(.{1})'; # catch bad bytes
+
+function toCodePoint($matches) {
+ global $points;
+ if ( $matches[1] != '' ) {
+ $points[]= ord($matches[1]);
+ } else if ( $matches[2] != '' ) {
+ $points[]= ( ( ord($matches[2][0]) % 32 ) * 64 ) + ( ord($matches[2][1]) % 64 );
+ } else if ( $matches[3] != '' ) {
+ $points[]= ( ( ord($matches[3][0]) % 16 ) * 4096 ) + ( ( ord($matches[3][1]) % 64 ) * 64 ) + ( ord($matches[3][2]) % 64 );
+ } else if ( $matches[4] != '' ) {
+ trigger_error('Invalid byte in UTF-8',E_USER_WARNING);
+ return '';
+ }
+ return $matches[0];
+}
+
+$str = file_get_contents('../tests/data/utf8.html');
+$points = array();
+preg_replace_callback('/'.$UTF8_MATCH.'/S','toCodePoint',$str);
+print_r($points);
--- /dev/null
+<?php
+/**
+* @version $Id: core.php,v 1.5 2006/02/28 22:12:25 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+/**
+* Define UTF8_CORE as required
+*/
+if ( !defined('UTF8_CORE') ) {
+ define('UTF8_CORE',TRUE);
+}
+
+//--------------------------------------------------------------------
+/**
+* Wrapper round mb_strlen
+* Assumes you have mb_internal_encoding to UTF-8 already
+* Note: this function does not count bad bytes in the string - these
+* are simply ignored
+* @param string UTF-8 string
+* @return int number of UTF-8 characters in string
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strlen($str){
+ return mb_strlen($str);
+}
+
+
+//--------------------------------------------------------------------
+/**
+* Assumes mbstring internal encoding is set to UTF-8
+* Wrapper around mb_strpos
+* Find position of first occurrence of a string
+* @param string haystack
+* @param string needle (you should validate this with utf8_is_valid)
+* @param integer offset in characters (from left)
+* @return mixed integer position or FALSE on failure
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strpos($str, $search, $offset = FALSE){
+ if ( $offset === FALSE ) {
+ return mb_strpos($str, $search);
+ } else {
+ return mb_strpos($str, $search, $offset);
+ }
+}
+
+//--------------------------------------------------------------------
+/**
+* Assumes mbstring internal encoding is set to UTF-8
+* Wrapper around mb_strrpos
+* Find position of last occurrence of a char in a string
+* @param string haystack
+* @param string needle (you should validate this with utf8_is_valid)
+* @param integer (optional) offset (from left)
+* @return mixed integer position or FALSE on failure
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strrpos($str, $search, $offset = FALSE){
+ if ( $offset === FALSE ) {
+ # Emulate behaviour of strrpos rather than raising warning
+ if ( empty($str) ) {
+ return FALSE;
+ }
+ return mb_strrpos($str, $search);
+ } else {
+ if ( !is_int($offset) ) {
+ trigger_error('utf8_strrpos expects parameter 3 to be long',E_USER_WARNING);
+ return FALSE;
+ }
+
+ $str = mb_substr($str, $offset);
+
+ if ( FALSE !== ( $pos = mb_strrpos($str, $search) ) ) {
+ return $pos + $offset;
+ }
+
+ return FALSE;
+ }
+}
+
+//--------------------------------------------------------------------
+/**
+* Assumes mbstring internal encoding is set to UTF-8
+* Wrapper around mb_substr
+* Return part of a string given character offset (and optionally length)
+* @param string
+* @param integer number of UTF-8 characters offset (from left)
+* @param integer (optional) length in UTF-8 characters from offset
+* @return mixed string or FALSE if failure
+* @package utf8
+* @subpackage strings
+*/
+function utf8_substr($str, $offset, $length = FALSE){
+ if ( $length === FALSE ) {
+ return mb_substr($str, $offset);
+ } else {
+ return mb_substr($str, $offset, $length);
+ }
+}
+
+//--------------------------------------------------------------------
+/**
+* Assumes mbstring internal encoding is set to UTF-8
+* Wrapper around mb_strtolower
+* Make a string lowercase
+* Note: The concept of a characters "case" only exists is some alphabets
+* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
+* not exist in the Chinese alphabet, for example. See Unicode Standard
+* Annex #21: Case Mappings
+* @param string
+* @return mixed either string in lowercase or FALSE is UTF-8 invalid
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strtolower($str){
+ return mb_strtolower($str);
+}
+
+//--------------------------------------------------------------------
+/**
+* Assumes mbstring internal encoding is set to UTF-8
+* Wrapper around mb_strtoupper
+* Make a string uppercase
+* Note: The concept of a characters "case" only exists is some alphabets
+* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
+* not exist in the Chinese alphabet, for example. See Unicode Standard
+* Annex #21: Case Mappings
+* @param string
+* @return mixed either string in lowercase or FALSE is UTF-8 invalid
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strtoupper($str){
+ return mb_strtoupper($str);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: core.php,v 1.9 2007/08/12 01:11:33 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+/**
+* Define UTF8_CORE as required
+*/
+if ( !defined('UTF8_CORE') ) {
+ define('UTF8_CORE',TRUE);
+}
+
+//--------------------------------------------------------------------
+/**
+* Unicode aware replacement for strlen(). Returns the number
+* of characters in the string (not the number of bytes), replacing
+* multibyte characters with a single byte equivalent
+* utf8_decode() converts characters that are not in ISO-8859-1
+* to '?', which, for the purpose of counting, is alright - It's
+* much faster than iconv_strlen
+* Note: this function does not count bad UTF-8 bytes in the string
+* - these are simply ignored
+* @author <chernyshevsky at hotmail dot com>
+* @link http://www.php.net/manual/en/function.strlen.php
+* @link http://www.php.net/manual/en/function.utf8-decode.php
+* @param string UTF-8 string
+* @return int number of UTF-8 characters in string
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strlen($str){
+ return strlen(utf8_decode($str));
+}
+
+
+//--------------------------------------------------------------------
+/**
+* UTF-8 aware alternative to strpos
+* Find position of first occurrence of a string
+* Note: This will get alot slower if offset is used
+* Note: requires utf8_strlen amd utf8_substr to be loaded
+* @param string haystack
+* @param string needle (you should validate this with utf8_is_valid)
+* @param integer offset in characters (from left)
+* @return mixed integer position or FALSE on failure
+* @see http://www.php.net/strpos
+* @see utf8_strlen
+* @see utf8_substr
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strpos($str, $needle, $offset = NULL) {
+
+ if ( is_null($offset) ) {
+
+ $ar = explode($needle, $str, 2);
+ if ( count($ar) > 1 ) {
+ return utf8_strlen($ar[0]);
+ }
+ return FALSE;
+
+ } else {
+
+ if ( !is_int($offset) ) {
+ trigger_error('utf8_strpos: Offset must be an integer',E_USER_ERROR);
+ return FALSE;
+ }
+
+ $str = utf8_substr($str, $offset);
+
+ if ( FALSE !== ( $pos = utf8_strpos($str, $needle) ) ) {
+ return $pos + $offset;
+ }
+
+ return FALSE;
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* UTF-8 aware alternative to strrpos
+* Find position of last occurrence of a char in a string
+* Note: This will get alot slower if offset is used
+* Note: requires utf8_substr and utf8_strlen to be loaded
+* @param string haystack
+* @param string needle (you should validate this with utf8_is_valid)
+* @param integer (optional) offset (from left)
+* @return mixed integer position or FALSE on failure
+* @see http://www.php.net/strrpos
+* @see utf8_substr
+* @see utf8_strlen
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strrpos($str, $needle, $offset = NULL) {
+
+ if ( is_null($offset) ) {
+
+ $ar = explode($needle, $str);
+
+ if ( count($ar) > 1 ) {
+ // Pop off the end of the string where the last match was made
+ array_pop($ar);
+ $str = join($needle,$ar);
+ return utf8_strlen($str);
+ }
+ return FALSE;
+
+ } else {
+
+ if ( !is_int($offset) ) {
+ trigger_error('utf8_strrpos expects parameter 3 to be long',E_USER_WARNING);
+ return FALSE;
+ }
+
+ $str = utf8_substr($str, $offset);
+
+ if ( FALSE !== ( $pos = utf8_strrpos($str, $needle) ) ) {
+ return $pos + $offset;
+ }
+
+ return FALSE;
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* UTF-8 aware alternative to substr
+* Return part of a string given character offset (and optionally length)
+*
+* Note arguments: comparied to substr - if offset or length are
+* not integers, this version will not complain but rather massages them
+* into an integer.
+*
+* Note on returned values: substr documentation states false can be
+* returned in some cases (e.g. offset > string length)
+* mb_substr never returns false, it will return an empty string instead.
+* This adopts the mb_substr approach
+*
+* Note on implementation: PCRE only supports repetitions of less than
+* 65536, in order to accept up to MAXINT values for offset and length,
+* we'll repeat a group of 65535 characters when needed.
+*
+* Note on implementation: calculating the number of characters in the
+* string is a relatively expensive operation, so we only carry it out when
+* necessary. It isn't necessary for +ve offsets and no specified length
+*
+* @author Chris Smith<chris@jalakai.co.uk>
+* @param string
+* @param integer number of UTF-8 characters offset (from left)
+* @param integer (optional) length in UTF-8 characters from offset
+* @return mixed string or FALSE if failure
+* @package utf8
+* @subpackage strings
+*/
+function utf8_substr($str, $offset, $length = NULL) {
+
+ // generates E_NOTICE
+ // for PHP4 objects, but not PHP5 objects
+ $str = (string)$str;
+ $offset = (int)$offset;
+ if (!is_null($length)) $length = (int)$length;
+
+ // handle trivial cases
+ if ($length === 0) return '';
+ if ($offset < 0 && $length < 0 && $length < $offset)
+ return '';
+
+ // normalise negative offsets (we could use a tail
+ // anchored pattern, but they are horribly slow!)
+ if ($offset < 0) {
+
+ // see notes
+ $strlen = strlen(utf8_decode($str));
+ $offset = $strlen + $offset;
+ if ($offset < 0) $offset = 0;
+
+ }
+
+ $Op = '';
+ $Lp = '';
+
+ // establish a pattern for offset, a
+ // non-captured group equal in length to offset
+ if ($offset > 0) {
+
+ $Ox = (int)($offset/65535);
+ $Oy = $offset%65535;
+
+ if ($Ox) {
+ $Op = '(?:.{65535}){'.$Ox.'}';
+ }
+
+ $Op = '^(?:'.$Op.'.{'.$Oy.'})';
+
+ } else {
+
+ // offset == 0; just anchor the pattern
+ $Op = '^';
+
+ }
+
+ // establish a pattern for length
+ if (is_null($length)) {
+
+ // the rest of the string
+ $Lp = '(.*)$';
+
+ } else {
+
+ if (!isset($strlen)) {
+ // see notes
+ $strlen = strlen(utf8_decode($str));
+ }
+
+ // another trivial case
+ if ($offset > $strlen) return '';
+
+ if ($length > 0) {
+
+ // reduce any length that would
+ // go passed the end of the string
+ $length = min($strlen-$offset, $length);
+
+ $Lx = (int)( $length / 65535 );
+ $Ly = $length % 65535;
+
+ // negative length requires a captured group
+ // of length characters
+ if ($Lx) $Lp = '(?:.{65535}){'.$Lx.'}';
+ $Lp = '('.$Lp.'.{'.$Ly.'})';
+
+ } else if ($length < 0) {
+
+ if ( $length < ($offset - $strlen) ) {
+ return '';
+ }
+
+ $Lx = (int)((-$length)/65535);
+ $Ly = (-$length)%65535;
+
+ // negative length requires ... capture everything
+ // except a group of -length characters
+ // anchored at the tail-end of the string
+ if ($Lx) $Lp = '(?:.{65535}){'.$Lx.'}';
+ $Lp = '(.*)(?:'.$Lp.'.{'.$Ly.'})$';
+
+ }
+
+ }
+
+ if (!preg_match( '#'.$Op.$Lp.'#us',$str, $match )) {
+ return '';
+ }
+
+ return $match[1];
+
+}
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to strtolower
+* Make a string lowercase
+* Note: The concept of a characters "case" only exists is some alphabets
+* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
+* not exist in the Chinese alphabet, for example. See Unicode Standard
+* Annex #21: Case Mappings
+* Note: requires utf8_to_unicode and utf8_from_unicode
+* @author Andreas Gohr <andi@splitbrain.org>
+* @param string
+* @return mixed either string in lowercase or FALSE is UTF-8 invalid
+* @see http://www.php.net/strtolower
+* @see utf8_to_unicode
+* @see utf8_from_unicode
+* @see http://www.unicode.org/reports/tr21/tr21-5.html
+* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strtolower($string){
+
+ static $UTF8_UPPER_TO_LOWER = NULL;
+
+ if ( is_null($UTF8_UPPER_TO_LOWER) ) {
+ $UTF8_UPPER_TO_LOWER = array(
+ 0x0041=>0x0061, 0x03A6=>0x03C6, 0x0162=>0x0163, 0x00C5=>0x00E5, 0x0042=>0x0062,
+ 0x0139=>0x013A, 0x00C1=>0x00E1, 0x0141=>0x0142, 0x038E=>0x03CD, 0x0100=>0x0101,
+ 0x0490=>0x0491, 0x0394=>0x03B4, 0x015A=>0x015B, 0x0044=>0x0064, 0x0393=>0x03B3,
+ 0x00D4=>0x00F4, 0x042A=>0x044A, 0x0419=>0x0439, 0x0112=>0x0113, 0x041C=>0x043C,
+ 0x015E=>0x015F, 0x0143=>0x0144, 0x00CE=>0x00EE, 0x040E=>0x045E, 0x042F=>0x044F,
+ 0x039A=>0x03BA, 0x0154=>0x0155, 0x0049=>0x0069, 0x0053=>0x0073, 0x1E1E=>0x1E1F,
+ 0x0134=>0x0135, 0x0427=>0x0447, 0x03A0=>0x03C0, 0x0418=>0x0438, 0x00D3=>0x00F3,
+ 0x0420=>0x0440, 0x0404=>0x0454, 0x0415=>0x0435, 0x0429=>0x0449, 0x014A=>0x014B,
+ 0x0411=>0x0431, 0x0409=>0x0459, 0x1E02=>0x1E03, 0x00D6=>0x00F6, 0x00D9=>0x00F9,
+ 0x004E=>0x006E, 0x0401=>0x0451, 0x03A4=>0x03C4, 0x0423=>0x0443, 0x015C=>0x015D,
+ 0x0403=>0x0453, 0x03A8=>0x03C8, 0x0158=>0x0159, 0x0047=>0x0067, 0x00C4=>0x00E4,
+ 0x0386=>0x03AC, 0x0389=>0x03AE, 0x0166=>0x0167, 0x039E=>0x03BE, 0x0164=>0x0165,
+ 0x0116=>0x0117, 0x0108=>0x0109, 0x0056=>0x0076, 0x00DE=>0x00FE, 0x0156=>0x0157,
+ 0x00DA=>0x00FA, 0x1E60=>0x1E61, 0x1E82=>0x1E83, 0x00C2=>0x00E2, 0x0118=>0x0119,
+ 0x0145=>0x0146, 0x0050=>0x0070, 0x0150=>0x0151, 0x042E=>0x044E, 0x0128=>0x0129,
+ 0x03A7=>0x03C7, 0x013D=>0x013E, 0x0422=>0x0442, 0x005A=>0x007A, 0x0428=>0x0448,
+ 0x03A1=>0x03C1, 0x1E80=>0x1E81, 0x016C=>0x016D, 0x00D5=>0x00F5, 0x0055=>0x0075,
+ 0x0176=>0x0177, 0x00DC=>0x00FC, 0x1E56=>0x1E57, 0x03A3=>0x03C3, 0x041A=>0x043A,
+ 0x004D=>0x006D, 0x016A=>0x016B, 0x0170=>0x0171, 0x0424=>0x0444, 0x00CC=>0x00EC,
+ 0x0168=>0x0169, 0x039F=>0x03BF, 0x004B=>0x006B, 0x00D2=>0x00F2, 0x00C0=>0x00E0,
+ 0x0414=>0x0434, 0x03A9=>0x03C9, 0x1E6A=>0x1E6B, 0x00C3=>0x00E3, 0x042D=>0x044D,
+ 0x0416=>0x0436, 0x01A0=>0x01A1, 0x010C=>0x010D, 0x011C=>0x011D, 0x00D0=>0x00F0,
+ 0x013B=>0x013C, 0x040F=>0x045F, 0x040A=>0x045A, 0x00C8=>0x00E8, 0x03A5=>0x03C5,
+ 0x0046=>0x0066, 0x00DD=>0x00FD, 0x0043=>0x0063, 0x021A=>0x021B, 0x00CA=>0x00EA,
+ 0x0399=>0x03B9, 0x0179=>0x017A, 0x00CF=>0x00EF, 0x01AF=>0x01B0, 0x0045=>0x0065,
+ 0x039B=>0x03BB, 0x0398=>0x03B8, 0x039C=>0x03BC, 0x040C=>0x045C, 0x041F=>0x043F,
+ 0x042C=>0x044C, 0x00DE=>0x00FE, 0x00D0=>0x00F0, 0x1EF2=>0x1EF3, 0x0048=>0x0068,
+ 0x00CB=>0x00EB, 0x0110=>0x0111, 0x0413=>0x0433, 0x012E=>0x012F, 0x00C6=>0x00E6,
+ 0x0058=>0x0078, 0x0160=>0x0161, 0x016E=>0x016F, 0x0391=>0x03B1, 0x0407=>0x0457,
+ 0x0172=>0x0173, 0x0178=>0x00FF, 0x004F=>0x006F, 0x041B=>0x043B, 0x0395=>0x03B5,
+ 0x0425=>0x0445, 0x0120=>0x0121, 0x017D=>0x017E, 0x017B=>0x017C, 0x0396=>0x03B6,
+ 0x0392=>0x03B2, 0x0388=>0x03AD, 0x1E84=>0x1E85, 0x0174=>0x0175, 0x0051=>0x0071,
+ 0x0417=>0x0437, 0x1E0A=>0x1E0B, 0x0147=>0x0148, 0x0104=>0x0105, 0x0408=>0x0458,
+ 0x014C=>0x014D, 0x00CD=>0x00ED, 0x0059=>0x0079, 0x010A=>0x010B, 0x038F=>0x03CE,
+ 0x0052=>0x0072, 0x0410=>0x0430, 0x0405=>0x0455, 0x0402=>0x0452, 0x0126=>0x0127,
+ 0x0136=>0x0137, 0x012A=>0x012B, 0x038A=>0x03AF, 0x042B=>0x044B, 0x004C=>0x006C,
+ 0x0397=>0x03B7, 0x0124=>0x0125, 0x0218=>0x0219, 0x00DB=>0x00FB, 0x011E=>0x011F,
+ 0x041E=>0x043E, 0x1E40=>0x1E41, 0x039D=>0x03BD, 0x0106=>0x0107, 0x03AB=>0x03CB,
+ 0x0426=>0x0446, 0x00DE=>0x00FE, 0x00C7=>0x00E7, 0x03AA=>0x03CA, 0x0421=>0x0441,
+ 0x0412=>0x0432, 0x010E=>0x010F, 0x00D8=>0x00F8, 0x0057=>0x0077, 0x011A=>0x011B,
+ 0x0054=>0x0074, 0x004A=>0x006A, 0x040B=>0x045B, 0x0406=>0x0456, 0x0102=>0x0103,
+ 0x039B=>0x03BB, 0x00D1=>0x00F1, 0x041D=>0x043D, 0x038C=>0x03CC, 0x00C9=>0x00E9,
+ 0x00D0=>0x00F0, 0x0407=>0x0457, 0x0122=>0x0123,
+ );
+ }
+
+ $uni = utf8_to_unicode($string);
+
+ if ( !$uni ) {
+ return FALSE;
+ }
+
+ $cnt = count($uni);
+ for ($i=0; $i < $cnt; $i++){
+ if ( isset($UTF8_UPPER_TO_LOWER[$uni[$i]]) ) {
+ $uni[$i] = $UTF8_UPPER_TO_LOWER[$uni[$i]];
+ }
+ }
+
+ return utf8_from_unicode($uni);
+}
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to strtoupper
+* Make a string uppercase
+* Note: The concept of a characters "case" only exists is some alphabets
+* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
+* not exist in the Chinese alphabet, for example. See Unicode Standard
+* Annex #21: Case Mappings
+* Note: requires utf8_to_unicode and utf8_from_unicode
+* @author Andreas Gohr <andi@splitbrain.org>
+* @param string
+* @return mixed either string in lowercase or FALSE is UTF-8 invalid
+* @see http://www.php.net/strtoupper
+* @see utf8_to_unicode
+* @see utf8_from_unicode
+* @see http://www.unicode.org/reports/tr21/tr21-5.html
+* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strtoupper($string){
+
+ static $UTF8_LOWER_TO_UPPER = NULL;
+
+ if ( is_null($UTF8_LOWER_TO_UPPER) ) {
+ $UTF8_LOWER_TO_UPPER = array(
+ 0x0061=>0x0041, 0x03C6=>0x03A6, 0x0163=>0x0162, 0x00E5=>0x00C5, 0x0062=>0x0042,
+ 0x013A=>0x0139, 0x00E1=>0x00C1, 0x0142=>0x0141, 0x03CD=>0x038E, 0x0101=>0x0100,
+ 0x0491=>0x0490, 0x03B4=>0x0394, 0x015B=>0x015A, 0x0064=>0x0044, 0x03B3=>0x0393,
+ 0x00F4=>0x00D4, 0x044A=>0x042A, 0x0439=>0x0419, 0x0113=>0x0112, 0x043C=>0x041C,
+ 0x015F=>0x015E, 0x0144=>0x0143, 0x00EE=>0x00CE, 0x045E=>0x040E, 0x044F=>0x042F,
+ 0x03BA=>0x039A, 0x0155=>0x0154, 0x0069=>0x0049, 0x0073=>0x0053, 0x1E1F=>0x1E1E,
+ 0x0135=>0x0134, 0x0447=>0x0427, 0x03C0=>0x03A0, 0x0438=>0x0418, 0x00F3=>0x00D3,
+ 0x0440=>0x0420, 0x0454=>0x0404, 0x0435=>0x0415, 0x0449=>0x0429, 0x014B=>0x014A,
+ 0x0431=>0x0411, 0x0459=>0x0409, 0x1E03=>0x1E02, 0x00F6=>0x00D6, 0x00F9=>0x00D9,
+ 0x006E=>0x004E, 0x0451=>0x0401, 0x03C4=>0x03A4, 0x0443=>0x0423, 0x015D=>0x015C,
+ 0x0453=>0x0403, 0x03C8=>0x03A8, 0x0159=>0x0158, 0x0067=>0x0047, 0x00E4=>0x00C4,
+ 0x03AC=>0x0386, 0x03AE=>0x0389, 0x0167=>0x0166, 0x03BE=>0x039E, 0x0165=>0x0164,
+ 0x0117=>0x0116, 0x0109=>0x0108, 0x0076=>0x0056, 0x00FE=>0x00DE, 0x0157=>0x0156,
+ 0x00FA=>0x00DA, 0x1E61=>0x1E60, 0x1E83=>0x1E82, 0x00E2=>0x00C2, 0x0119=>0x0118,
+ 0x0146=>0x0145, 0x0070=>0x0050, 0x0151=>0x0150, 0x044E=>0x042E, 0x0129=>0x0128,
+ 0x03C7=>0x03A7, 0x013E=>0x013D, 0x0442=>0x0422, 0x007A=>0x005A, 0x0448=>0x0428,
+ 0x03C1=>0x03A1, 0x1E81=>0x1E80, 0x016D=>0x016C, 0x00F5=>0x00D5, 0x0075=>0x0055,
+ 0x0177=>0x0176, 0x00FC=>0x00DC, 0x1E57=>0x1E56, 0x03C3=>0x03A3, 0x043A=>0x041A,
+ 0x006D=>0x004D, 0x016B=>0x016A, 0x0171=>0x0170, 0x0444=>0x0424, 0x00EC=>0x00CC,
+ 0x0169=>0x0168, 0x03BF=>0x039F, 0x006B=>0x004B, 0x00F2=>0x00D2, 0x00E0=>0x00C0,
+ 0x0434=>0x0414, 0x03C9=>0x03A9, 0x1E6B=>0x1E6A, 0x00E3=>0x00C3, 0x044D=>0x042D,
+ 0x0436=>0x0416, 0x01A1=>0x01A0, 0x010D=>0x010C, 0x011D=>0x011C, 0x00F0=>0x00D0,
+ 0x013C=>0x013B, 0x045F=>0x040F, 0x045A=>0x040A, 0x00E8=>0x00C8, 0x03C5=>0x03A5,
+ 0x0066=>0x0046, 0x00FD=>0x00DD, 0x0063=>0x0043, 0x021B=>0x021A, 0x00EA=>0x00CA,
+ 0x03B9=>0x0399, 0x017A=>0x0179, 0x00EF=>0x00CF, 0x01B0=>0x01AF, 0x0065=>0x0045,
+ 0x03BB=>0x039B, 0x03B8=>0x0398, 0x03BC=>0x039C, 0x045C=>0x040C, 0x043F=>0x041F,
+ 0x044C=>0x042C, 0x00FE=>0x00DE, 0x00F0=>0x00D0, 0x1EF3=>0x1EF2, 0x0068=>0x0048,
+ 0x00EB=>0x00CB, 0x0111=>0x0110, 0x0433=>0x0413, 0x012F=>0x012E, 0x00E6=>0x00C6,
+ 0x0078=>0x0058, 0x0161=>0x0160, 0x016F=>0x016E, 0x03B1=>0x0391, 0x0457=>0x0407,
+ 0x0173=>0x0172, 0x00FF=>0x0178, 0x006F=>0x004F, 0x043B=>0x041B, 0x03B5=>0x0395,
+ 0x0445=>0x0425, 0x0121=>0x0120, 0x017E=>0x017D, 0x017C=>0x017B, 0x03B6=>0x0396,
+ 0x03B2=>0x0392, 0x03AD=>0x0388, 0x1E85=>0x1E84, 0x0175=>0x0174, 0x0071=>0x0051,
+ 0x0437=>0x0417, 0x1E0B=>0x1E0A, 0x0148=>0x0147, 0x0105=>0x0104, 0x0458=>0x0408,
+ 0x014D=>0x014C, 0x00ED=>0x00CD, 0x0079=>0x0059, 0x010B=>0x010A, 0x03CE=>0x038F,
+ 0x0072=>0x0052, 0x0430=>0x0410, 0x0455=>0x0405, 0x0452=>0x0402, 0x0127=>0x0126,
+ 0x0137=>0x0136, 0x012B=>0x012A, 0x03AF=>0x038A, 0x044B=>0x042B, 0x006C=>0x004C,
+ 0x03B7=>0x0397, 0x0125=>0x0124, 0x0219=>0x0218, 0x00FB=>0x00DB, 0x011F=>0x011E,
+ 0x043E=>0x041E, 0x1E41=>0x1E40, 0x03BD=>0x039D, 0x0107=>0x0106, 0x03CB=>0x03AB,
+ 0x0446=>0x0426, 0x00FE=>0x00DE, 0x00E7=>0x00C7, 0x03CA=>0x03AA, 0x0441=>0x0421,
+ 0x0432=>0x0412, 0x010F=>0x010E, 0x00F8=>0x00D8, 0x0077=>0x0057, 0x011B=>0x011A,
+ 0x0074=>0x0054, 0x006A=>0x004A, 0x045B=>0x040B, 0x0456=>0x0406, 0x0103=>0x0102,
+ 0x03BB=>0x039B, 0x00F1=>0x00D1, 0x043D=>0x041D, 0x03CC=>0x038C, 0x00E9=>0x00C9,
+ 0x00F0=>0x00D0, 0x0457=>0x0407, 0x0123=>0x0122,
+ );
+ }
+
+ $uni = utf8_to_unicode($string);
+
+ if ( !$uni ) {
+ return FALSE;
+ }
+
+ $cnt = count($uni);
+ for ($i=0; $i < $cnt; $i++){
+ if( isset($UTF8_LOWER_TO_UPPER[$uni[$i]]) ) {
+ $uni[$i] = $UTF8_LOWER_TO_UPPER[$uni[$i]];
+ }
+ }
+
+ return utf8_from_unicode($uni);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: ord.php,v 1.4 2006/09/11 15:22:54 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to ord
+* Returns the unicode ordinal for a character
+* @param string UTF-8 encoded character
+* @return int unicode ordinal for the character
+* @see http://www.php.net/ord
+* @see http://www.php.net/manual/en/function.ord.php#46267
+*/
+function utf8_ord($chr) {
+
+ $ord0 = ord($chr);
+
+ if ( $ord0 >= 0 && $ord0 <= 127 ) {
+ return $ord0;
+ }
+
+ if ( !isset($chr{1}) ) {
+ trigger_error('Short sequence - at least 2 bytes expected, only 1 seen');
+ return FALSE;
+ }
+
+ $ord1 = ord($chr{1});
+ if ( $ord0 >= 192 && $ord0 <= 223 ) {
+ return ( $ord0 - 192 ) * 64
+ + ( $ord1 - 128 );
+ }
+
+ if ( !isset($chr{2}) ) {
+ trigger_error('Short sequence - at least 3 bytes expected, only 2 seen');
+ return FALSE;
+ }
+ $ord2 = ord($chr{2});
+ if ( $ord0 >= 224 && $ord0 <= 239 ) {
+ return ($ord0-224)*4096
+ + ($ord1-128)*64
+ + ($ord2-128);
+ }
+
+ if ( !isset($chr{3}) ) {
+ trigger_error('Short sequence - at least 4 bytes expected, only 3 seen');
+ return FALSE;
+ }
+ $ord3 = ord($chr{3});
+ if ($ord0>=240 && $ord0<=247) {
+ return ($ord0-240)*262144
+ + ($ord1-128)*4096
+ + ($ord2-128)*64
+ + ($ord3-128);
+
+ }
+
+ if ( !isset($chr{4}) ) {
+ trigger_error('Short sequence - at least 5 bytes expected, only 4 seen');
+ return FALSE;
+ }
+ $ord4 = ord($chr{4});
+ if ($ord0>=248 && $ord0<=251) {
+ return ($ord0-248)*16777216
+ + ($ord1-128)*262144
+ + ($ord2-128)*4096
+ + ($ord3-128)*64
+ + ($ord4-128);
+ }
+
+ if ( !isset($chr{5}) ) {
+ trigger_error('Short sequence - at least 6 bytes expected, only 5 seen');
+ return FALSE;
+ }
+ if ($ord0>=252 && $ord0<=253) {
+ return ($ord0-252) * 1073741824
+ + ($ord1-128)*16777216
+ + ($ord2-128)*262144
+ + ($ord3-128)*4096
+ + ($ord4-128)*64
+ + (ord($c{5})-128);
+ }
+
+ if ( $ord0 >= 254 && $ord0 <= 255 ) {
+ trigger_error('Invalid UTF-8 with surrogate ordinal '.$ord0);
+ return FALSE;
+ }
+
+}
+
--- /dev/null
+<?php
+/**
+* @version $Id: str_ireplace.php,v 1.2 2007/08/12 01:20:46 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to str_ireplace
+* Case-insensitive version of str_replace
+* Note: requires utf8_strtolower
+* Note: it's not fast and gets slower if $search / $replace is array
+* Notes: it's based on the assumption that the lower and uppercase
+* versions of a UTF-8 character will have the same length in bytes
+* which is currently true given the hash table to strtolower
+* @param string
+* @return string
+* @see http://www.php.net/str_ireplace
+* @see utf8_strtolower
+* @package utf8
+* @subpackage strings
+*/
+function utf8_ireplace($search, $replace, $str, $count = NULL){
+
+ if ( !is_array($search) ) {
+
+ $slen = strlen($search);
+ if ( $slen == 0 ) {
+ return $str;
+ }
+
+ $lendif = strlen($replace) - strlen($search);
+ $search = utf8_strtolower($search);
+
+ $search = preg_quote($search);
+ $lstr = utf8_strtolower($str);
+ $i = 0;
+ $matched = 0;
+ while ( preg_match('/(.*)'.$search.'/Us',$lstr, $matches) ) {
+ if ( $i === $count ) {
+ break;
+ }
+ $mlen = strlen($matches[0]);
+ $lstr = substr($lstr, $mlen);
+ $str = substr_replace($str, $replace, $matched+strlen($matches[1]), $slen);
+ $matched += $mlen + $lendif;
+ $i++;
+ }
+ return $str;
+
+ } else {
+
+ foreach ( array_keys($search) as $k ) {
+
+ if ( is_array($replace) ) {
+
+ if ( array_key_exists($k,$replace) ) {
+
+ $str = utf8_ireplace($search[$k], $replace[$k], $str, $count);
+
+ } else {
+
+ $str = utf8_ireplace($search[$k], '', $str, $count);
+
+ }
+
+ } else {
+
+ $str = utf8_ireplace($search[$k], $replace, $str, $count);
+
+ }
+ }
+ return $str;
+
+ }
+
+}
+
+
--- /dev/null
+<?php
+/**
+* @version $Id: str_pad.php,v 1.1 2006/09/03 09:25:13 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* Replacement for str_pad. $padStr may contain multi-byte characters.
+*
+* @author Oliver Saunders <oliver (a) osinternetservices.com>
+* @param string $input
+* @param int $length
+* @param string $padStr
+* @param int $type ( same constants as str_pad )
+* @return string
+* @see http://www.php.net/str_pad
+* @see utf8_substr
+* @package utf8
+* @subpackage strings
+*/
+function utf8_str_pad($input, $length, $padStr = ' ', $type = STR_PAD_RIGHT) {
+
+ $inputLen = utf8_strlen($input);
+ if ($length <= $inputLen) {
+ return $input;
+ }
+
+ $padStrLen = utf8_strlen($padStr);
+ $padLen = $length - $inputLen;
+
+ if ($type == STR_PAD_RIGHT) {
+ $repeatTimes = ceil($padLen / $padStrLen);
+ return utf8_substr($input . str_repeat($padStr, $repeatTimes), 0, $length);
+ }
+
+ if ($type == STR_PAD_LEFT) {
+ $repeatTimes = ceil($padLen / $padStrLen);
+ return utf8_substr(str_repeat($padStr, $repeatTimes), 0, floor($padLen)) . $input;
+ }
+
+ if ($type == STR_PAD_BOTH) {
+
+ $padLen/= 2;
+ $padAmountLeft = floor($padLen);
+ $padAmountRight = ceil($padLen);
+ $repeatTimesLeft = ceil($padAmountLeft / $padStrLen);
+ $repeatTimesRight = ceil($padAmountRight / $padStrLen);
+
+ $paddingLeft = utf8_substr(str_repeat($padStr, $repeatTimesLeft), 0, $padAmountLeft);
+ $paddingRight = utf8_substr(str_repeat($padStr, $repeatTimesRight), 0, $padAmountLeft);
+ return $paddingLeft . $input . $paddingRight;
+ }
+
+ trigger_error('utf8_str_pad: Unknown padding type (' . $type . ')',E_USER_ERROR);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: str_split.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to str_split
+* Convert a string to an array
+* Note: requires utf8_strlen to be loaded
+* @param string UTF-8 encoded
+* @param int number to characters to split string by
+* @return string characters in string reverses
+* @see http://www.php.net/str_split
+* @see utf8_strlen
+* @package utf8
+* @subpackage strings
+*/
+function utf8_str_split($str, $split_len = 1) {
+
+ if ( !preg_match('/^[0-9]+$/',$split_len) || $split_len < 1 ) {
+ return FALSE;
+ }
+
+ $len = utf8_strlen($str);
+ if ( $len <= $split_len ) {
+ return array($str);
+ }
+
+ preg_match_all('/.{'.$split_len.'}|[^\x00]{1,'.$split_len.'}$/us', $str, $ar);
+ return $ar[0];
+
+}
--- /dev/null
+<?php
+/**
+* @version $Id: strcasecmp.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to strcasecmp
+* A case insensivite string comparison
+* Note: requires utf8_strtolower
+* @param string
+* @param string
+* @return int
+* @see http://www.php.net/strcasecmp
+* @see utf8_strtolower
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strcasecmp($strX, $strY) {
+ $strX = utf8_strtolower($strX);
+ $strY = utf8_strtolower($strY);
+ return strcmp($strX, $strY);
+}
+
--- /dev/null
+<?php
+/**
+* @version $Id: strcspn.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to strcspn
+* Find length of initial segment not matching mask
+* Note: requires utf8_strlen and utf8_substr (if start, length are used)
+* @param string
+* @return int
+* @see http://www.php.net/strcspn
+* @see utf8_strlen
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strcspn($str, $mask, $start = NULL, $length = NULL) {
+
+ if ( empty($mask) || strlen($mask) == 0 ) {
+ return NULL;
+ }
+
+ $mask = preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$mask);
+
+ if ( $start !== NULL || $length !== NULL ) {
+ $str = utf8_substr($str, $start, $length);
+ }
+
+ preg_match('/^[^'.$mask.']+/u',$str, $matches);
+
+ if ( isset($matches[0]) ) {
+ return utf8_strlen($matches[0]);
+ }
+
+ return 0;
+
+}
+
--- /dev/null
+<?php
+/**
+* @version $Id: stristr.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to stristr
+* Find first occurrence of a string using case insensitive comparison
+* Note: requires utf8_strtolower
+* @param string
+* @param string
+* @return int
+* @see http://www.php.net/strcasecmp
+* @see utf8_strtolower
+* @package utf8
+* @subpackage strings
+*/
+function utf8_stristr($str, $search) {
+
+ if ( strlen($search) == 0 ) {
+ return $str;
+ }
+
+ $lstr = utf8_strtolower($str);
+ $lsearch = utf8_strtolower($search);
+ preg_match('/^(.*)'.preg_quote($lsearch).'/Us',$lstr, $matches);
+
+ if ( count($matches) == 2 ) {
+ return substr($str, strlen($matches[1]));
+ }
+
+ return FALSE;
+}
--- /dev/null
+<?php
+/**
+* @version $Id: strrev.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to strrev
+* Reverse a string
+* @param string UTF-8 encoded
+* @return string characters in string reverses
+* @see http://www.php.net/strrev
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strrev($str){
+ preg_match_all('/./us', $str, $ar);
+ return join('',array_reverse($ar[0]));
+}
+
--- /dev/null
+<?php
+/**
+* @version $Id: strspn.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware alternative to strspn
+* Find length of initial segment matching mask
+* Note: requires utf8_strlen and utf8_substr (if start, length are used)
+* @param string
+* @return int
+* @see http://www.php.net/strspn
+* @package utf8
+* @subpackage strings
+*/
+function utf8_strspn($str, $mask, $start = NULL, $length = NULL) {
+
+ $mask = preg_replace('!([\\\\\\-\\]\\[/^])!','\\\${1}',$mask);
+
+ if ( $start !== NULL || $length !== NULL ) {
+ $str = utf8_substr($str, $start, $length);
+ }
+
+ preg_match('/^['.$mask.']+/u',$str, $matches);
+
+ if ( isset($matches[0]) ) {
+ return utf8_strlen($matches[0]);
+ }
+
+ return 0;
+
+}
+
--- /dev/null
+<?php
+/**
+* @version $Id: substr_replace.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
+* @package utf8
+* @subpackage strings
+*/
+
+//---------------------------------------------------------------
+/**
+* UTF-8 aware substr_replace.
+* Note: requires utf8_substr to be loaded
+* @see http://www.php.net/substr_replace
+* @see utf8_strlen
+* @see utf8_substr
+*/
+function utf8_substr_replace($str, $repl, $start , $length = NULL ) {
+ preg_match_all('/./us', $str, $ar);
+ preg_match_all('/./us', $repl, $rar);
+ if( $length === NULL ) {
+ $length = utf8_strlen($str);
+ }
+ array_splice( $ar[0], $start, $length, $rar[0] );
+ return join('',$ar[0]);
+}
--- /dev/null
+<?php
+require_once dirname(__FILE__).'/../benchconfig.php';
+print utf8_strlen(file_get_contents(UTF8DATA . '/utf8.html' ))."\n";
+?>
--- /dev/null
+<?php
+require_once dirname(__FILE__).'/../benchconfig.php';
+$page = file_get_contents(UTF8DATA . '/utf8.html' );
+foreach ( range('A', 'Z') as $char ) {
+ print utf8_strpos($page, $char)."\n";
+}
+?>
--- /dev/null
+<?php
+require_once dirname(__FILE__).'/../benchconfig.php';
+$page = file_get_contents(UTF8DATA . '/utf8.html' );
+foreach ( range('A', 'Z') as $char ) {
+ print utf8_strrpos($page, $char)."\n";
+}
+?>
--- /dev/null
+<?php
+require_once dirname(__FILE__).'/../benchconfig.php';
+$page = file_get_contents(UTF8DATA . '/utf8.html' );
+for($i = 0; $i < 37919; $i+= 1000) {
+ utf8_substr($page, $i);
+}
+print "Done\n";
+?>
--- /dev/null
+<?php
+//--------------------------------------------------------------------
+if ( !defined('UTF8') ) {
+ define('UTF8',realpath(dirname(__FILE__).'/../'));
+}
+
+if ( !defined('UTF8DATA') ) {
+ define('UTF8DATA',dirname(__FILE__).'/data');
+}
+
+
+
+if ( !isset($_GET['engine']) ) {
+ $_GET['engine'] = 'auto';
+}
+
+/**
+* Testing against a particular "engine"
+*/
+switch ( $_GET['engine'] ) {
+ case 'mbstring';
+ if ( !function_exists('mb_strtolower') ) {
+ trigger_error("mbstring extension not detected on your system!", E_USER_ERROR );
+ }
+ mb_internal_encoding('UTF-8');
+ require_once UTF8 . '/mbstring/core.php';
+ break;
+ case 'native':
+ require_once UTF8 . '/utils/unicode.php';
+ require_once UTF8 . '/native/core.php';
+ break;
+}
+
+require_once UTF8 . '/utf8.php';
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_ascii.test.php,v 1.9 2006/10/17 08:53:37 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/utils/ascii.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_is_ascii extends UnitTestCase {
+
+ function test_utf8_is_ascii() {
+ $this->UnitTestCase('test_utf8_is_ascii()');
+ }
+
+ function testUtf8() {
+ $str = 'testiñg';
+ $this->assertFalse(utf8_is_ascii($str));
+ }
+
+ function testAscii() {
+ $str = 'testing';
+ $this->assertTrue(utf8_is_ascii($str));
+ }
+
+ function testInvalidChar() {
+ $str = "tes\xe9ting";
+ $this->assertFalse(utf8_is_ascii($str));
+ }
+
+ function testEmptyStr() {
+ $str = '';
+ $this->assertTrue(utf8_is_ascii($str));
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strip_non_ascii extends UnitTestCase {
+
+ function test_utf8_strip_non_ascii() {
+ $this->UnitTestCase('test_utf8_strip_non_ascii()');
+ }
+
+ function testUtf8() {
+ $str = 'testiñg';
+ $this->assertEqual(utf8_strip_non_ascii($str),'testig');
+ }
+
+ function testAscii() {
+ $str = 'testing';
+ $this->assertEqual(utf8_strip_non_ascii($str),'testing');
+ }
+
+ function testInvalidChar() {
+ $str = "tes\xe9ting";
+ $this->assertEqual(utf8_strip_non_ascii($str),'testing');
+ }
+
+ function testEmptyStr() {
+ $str = '';
+ $this->assertEqual(utf8_strip_non_ascii($str),'');
+ }
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strip_non_ascii_ctrl extends UnitTestCase{
+
+ function test_utf8_strip_non_ascii_ctrl() {
+ $this->UnitTestCase('test_utf8_strip_non_ascii_ctrl');
+ }
+
+ function testNulAndNon7Bit() {
+ $str = "a\x00ñ\x00c";
+ $this->assertEqual(utf8_strip_non_ascii_ctrl($str),'ac');
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strip_ascii_ctrl extends UnitTestCase{
+
+ function test_utf8_strip_ascii_ctrl() {
+ $this->UnitTestCase('test_utf8_strip_ascii_ctrl');
+ }
+
+ function testNul() {
+ $str = "a\x00b\x00c";
+ $this->assertEqual(utf8_strip_ascii_ctrl($str),'abc');
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_accents_to_ascii extends UnitTestCase{
+
+ function test_utf8_accents_to_ascii() {
+ $this->UnitTestCase('test_utf8_accents_to_ascii');
+ }
+
+ function testEmptyStr() {
+ $this->assertEqual(utf8_accents_to_ascii(''),'');
+ }
+
+ function testLowercase() {
+ $str = "ô";
+ $this->assertEqual(utf8_accents_to_ascii($str,-1),'o');
+ }
+
+ function testUppercase() {
+ $str = "Ô";
+ $this->assertEqual(utf8_accents_to_ascii($str,1),'O');
+ }
+
+ function testBoth() {
+ $str = "ôÔ";
+ $this->assertEqual(utf8_accents_to_ascii($str,0),'oO');
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new GroupTest('utf8_ascii');
+ $test->addTestCase(new test_utf8_is_ascii());
+ $test->addTestCase(new test_utf8_strip_non_ascii());
+ $test->addTestCase(new test_utf8_strip_non_ascii_ctrl());
+ $test->addTestCase(new test_utf8_strip_ascii_ctrl());
+ $test->addTestCase(new test_utf8_accents_to_ascii());
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_bad.test.php,v 1.6 2006/02/26 13:39:37 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/utils/bad.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_bad_find extends UnitTestCase {
+
+ function test_utf8_bad_find() {
+ $this->UnitTestCase('utf8_bad_find()');
+ }
+
+ function testValidUtf8() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertFalse(utf8_bad_find($str));
+ }
+
+ function testValidUtf8Ascii() {
+ $str = 'testing';
+ $this->assertFalse(utf8_bad_find($str));
+ }
+
+ function testInvalidUtf8() {
+ $str = "Iñtërnâtiôn\xe9àlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),15);
+ }
+
+ function testInvalidUtf8Ascii() {
+ $str = "this is an invalid char '\xe9' here";
+ $this->assertEqual(utf8_bad_find($str),25);
+ }
+
+ function testInvalidUtf8Start() {
+ $str = "\xe9Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),0);
+ }
+
+ function testInvalidUtf8End() {
+ $str = "Iñtërnâtiônàlizætiøn\xe9";
+ $this->assertEqual(utf8_bad_find($str),27);
+ }
+
+ function testValidTwoOctetId() {
+ $str = "abc\xc3\xb1";
+ $this->assertFalse(utf8_bad_find($str));
+ }
+
+ function testInvalidTwoOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn \xc3\x28 Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),28);
+ }
+
+ function testInvalidIdBetweenTwoAndThree() {
+ $str = "Iñtërnâtiônàlizætiøn\xa0\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),27);
+ }
+
+
+ function testValidThreeOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertFalse(utf8_bad_find($str));
+ }
+
+
+ function testInvalidThreeOctetSequenceSecond() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x28\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),27);
+ }
+
+ function testInvalidThreeOctetSequenceThird() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\x28Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),27);
+ }
+
+ function testValidFourOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x90\x8c\xbcIñtërnâtiônàlizætiøn";
+ $this->assertFalse(utf8_bad_find($str));
+ }
+
+ function testInvalidFourOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x28\x8c\xbcIñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),27);
+ }
+
+ function testInvalidFiveOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf8\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),27);
+ }
+
+ function testInvalidSixOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xfc\xa1\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),27);
+ }
+
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_bad_findall extends UnitTestCase {
+
+ function test_utf8_bad_findall() {
+ $this->UnitTestCase('test_utf8_bad_findall()');
+ }
+
+ function testValidUtf8() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertFalse(utf8_bad_findall($str));
+ }
+
+ function testValidUtf8Ascii() {
+ $str = 'testing';
+ $this->assertFalse(utf8_bad_findall($str));
+ }
+
+ function testInvalidUtf8() {
+ $str = "Iñtërnâtiôn\xe9àlizætiøn";
+ $test = array(15);
+ $this->assertEqual(utf8_bad_findall($str),$test);
+ }
+
+ function testInvalidUtf8Ascii() {
+ $str = "this is an invalid char '\xe9' here";
+ $test = array(25);
+ $this->assertEqual(utf8_bad_findall($str),$test);
+ }
+
+ function testInvalidUtf8Multiple() {
+ $str = "\xe9Iñtërnâtiôn\xe9àlizætiøn\xe9";
+ $test = array(0,16,29);
+ $this->assertEqual(utf8_bad_findall($str),$test);
+ }
+
+ function testValidTwoOctetId() {
+ $str = "abc\xc3\xb1";
+ $this->assertFalse(utf8_bad_findall($str));
+ }
+
+ function testInvalidTwoOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn \xc3\x28 Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_findall($str),array(28));
+ }
+
+ function testInvalidIdBetweenTwoAndThree() {
+ $str = "Iñtërnâtiônàlizætiøn\xa0\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_findall($str),array(27,28));
+ }
+
+ function testValidThreeOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertFalse(utf8_bad_findall($str));
+ }
+
+ function testInvalidThreeOctetSequenceSecond() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x28\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_findall($str),array(27,29));
+ }
+
+ function testInvalidThreeOctetSequenceThird() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\x28Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_find($str),27);
+ }
+
+ function testValidFourOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x90\x8c\xbcIñtërnâtiônàlizætiøn";
+ $this->assertFalse(utf8_bad_findall($str));
+ }
+
+ function testInvalidFourOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x28\x8c\xbcIñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_findall($str),array(27,29,30));
+ }
+
+ function testInvalidFiveOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf8\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_findall($str),range(27,31));
+ }
+
+ function testInvalidSixOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xfc\xa1\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_findall($str),range(27,32));
+ }
+
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_bad_strip extends UnitTestCase {
+
+ function test_utf8_bad_strip() {
+ $this->UnitTestCase('test_utf8_bad_strip()');
+ }
+
+ function testValidUtf8() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_bad_strip($str),$str);
+ }
+
+ function testValidUtf8Ascii() {
+ $str = 'testing';
+ $this->assertEqual(utf8_bad_strip($str),$str);
+ }
+
+ function testInvalidUtf8() {
+ $str = "Iñtërnâtiôn\xe9àlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),'Iñtërnâtiônàlizætiøn');
+ }
+
+ function testInvalidUtf8Ascii() {
+ $str = "this is an invalid char '\xe9' here";
+ $this->assertEqual(utf8_bad_strip($str),"this is an invalid char '' here");
+ }
+
+ function testInvalidUtf8Multiple() {
+ $str = "\xe9Iñtërnâtiôn\xe9àlizætiøn\xe9";
+ $this->assertEqual(utf8_bad_strip($str),'Iñtërnâtiônàlizætiøn');
+ }
+
+ function testValidTwoOctetId() {
+ $str = "abc\xc3\xb1";
+ $this->assertEqual(utf8_bad_strip($str),$str);
+ }
+
+ function testInvalidTwoOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn \xc3\x28 Iñtërnâtiônàlizætiøn";
+ $stripped = "Iñtërnâtiônàlizætiøn \x28 Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),$stripped);
+ }
+
+ function testInvalidIdBetweenTwoAndThree() {
+ $str = "Iñtërnâtiônàlizætiøn\xa0\xa1Iñtërnâtiônàlizætiøn";
+ $stripped = "IñtërnâtiônàlizætiønIñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),$stripped);
+ }
+
+ function testValidThreeOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),$str);
+ }
+
+ function testInvalidThreeOctetSequenceSecond() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x28\xa1Iñtërnâtiônàlizætiøn";
+ $stripped = "Iñtërnâtiônàlizætiøn(Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),$stripped);
+ }
+
+ function testInvalidThreeOctetSequenceThird() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\x28Iñtërnâtiônàlizætiøn";
+ $stripped = "Iñtërnâtiônàlizætiøn(Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),$stripped);
+ }
+
+ function testValidFourOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x90\x8c\xbcIñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),$str);
+ }
+
+ function testInvalidFourOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x28\x8c\xbcIñtërnâtiônàlizætiøn";
+ $stripped = "Iñtërnâtiônàlizætiøn(Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),$stripped);
+ }
+
+ function testInvalidFiveOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf8\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $stripped = "IñtërnâtiônàlizætiønIñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),$stripped);
+ }
+
+ function testInvalidSixOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xfc\xa1\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $stripped = "IñtërnâtiônàlizætiønIñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_strip($str),$stripped);
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_bad_replace extends UnitTestCase {
+
+ function test_utf8_bad_replace() {
+ $this->UnitTestCase('test_utf8_bad_replace()');
+ }
+
+ function testValidUtf8() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_bad_replace($str),$str);
+ }
+
+ function testValidUtf8Ascii() {
+ $str = 'testing';
+ $this->assertEqual(utf8_bad_replace($str),$str);
+ }
+
+ function testInvalidUtf8() {
+ $str = "Iñtërnâtiôn\xe9àlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),'Iñtërnâtiôn?àlizætiøn');
+ }
+
+ function testInvalidUtf8WithX() {
+ $str = "Iñtërnâtiôn\xe9àlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str,'X'),'IñtërnâtiônXàlizætiøn');
+ }
+
+ function testInvalidUtf8Ascii() {
+ $str = "this is an invalid char '\xe9' here";
+ $this->assertEqual(utf8_bad_replace($str),"this is an invalid char '?' here");
+ }
+
+ function testInvalidUtf8Multiple() {
+ $str = "\xe9Iñtërnâtiôn\xe9àlizætiøn\xe9";
+ $this->assertEqual(utf8_bad_replace($str),'?Iñtërnâtiôn?àlizætiøn?');
+ }
+
+ function testValidTwoOctetId() {
+ $str = "abc\xc3\xb1";
+ $this->assertEqual(utf8_bad_replace($str),$str);
+ }
+
+ function testInvalidTwoOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn \xc3\x28 Iñtërnâtiônàlizætiøn";
+ $replaced= "Iñtërnâtiônàlizætiøn ?( Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),$replaced);
+ }
+
+ function testInvalidIdBetweenTwoAndThree() {
+ $str = "Iñtërnâtiônàlizætiøn\xa0\xa1Iñtërnâtiônàlizætiøn";
+ $replaced= "Iñtërnâtiônàlizætiøn??Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),$replaced);
+ }
+
+ function testValidThreeOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),$str);
+ }
+
+ function testInvalidThreeOctetSequenceSecond() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x28\xa1Iñtërnâtiônàlizætiøn";
+ $replaced= "Iñtërnâtiônàlizætiøn?(?Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),$replaced);
+ }
+
+ function testInvalidThreeOctetSequenceThird() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\x28Iñtërnâtiônàlizætiøn";
+ $replaced= "Iñtërnâtiônàlizætiøn??(Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),$replaced);
+ }
+
+ function testValidFourOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x90\x8c\xbcIñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),$str);
+ }
+
+ function testInvalidFourOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x28\x8c\xbcIñtërnâtiônàlizætiøn";
+ $replaced= "Iñtërnâtiônàlizætiøn?(??Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),$replaced);
+ }
+
+ function testInvalidFiveOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf8\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $replaced= "Iñtërnâtiônàlizætiøn?????Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),$replaced);
+ }
+
+ function testInvalidSixOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xfc\xa1\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $replaced= "Iñtërnâtiônàlizætiøn??????Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_replace($str),$replaced);
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_bad_identify extends UnitTestCase {
+
+ function test_utf8_bad_identify() {
+ $this->UnitTestCase('utf8_bad_identify()');
+ }
+
+ function testValidUtf8() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertFalse(utf8_bad_identify($str,$i));
+ $this->assertNull($i);
+ }
+
+ function testValidUtf8Ascii() {
+ $str = 'testing';
+ $this->assertFalse(utf8_bad_identify($str,$i));
+ $this->assertNull($i);
+ }
+
+ function testInvalidUtf8() {
+ $str = "Iñtërnâtiôn\xe9àlizætiøn";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_SEQINCOMPLETE);
+ $this->assertEqual($i,15);
+ }
+
+ function testInvalidUtf8Ascii() {
+ $str = "this is an invalid char '\xe9' here";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_SEQINCOMPLETE);
+ $this->assertEqual($i,25);
+ }
+
+ function testInvalidUtf8Start() {
+ $str = "\xe9Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_SEQINCOMPLETE);
+ $this->assertEqual($i,0);
+ }
+
+ function testInvalidUtf8End() {
+ $str = "Iñtërnâtiônàlizætiøn\xe9";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_SEQINCOMPLETE);
+ $this->assertEqual($i,27);
+ }
+
+ function testValidTwoOctetId() {
+ $str = "abc\xc3\xb1";
+ $this->assertFalse(utf8_bad_identify($str,$i));
+ $this->assertNull($i);
+ }
+
+ function testInvalidTwoOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn \xc3\x28 Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_SEQINCOMPLETE);
+ $this->assertEqual($i,28);
+ }
+
+ function testInvalidIdBetweenTwoAndThree() {
+ $str = "Iñtërnâtiônàlizætiøn\xa0\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_SEQID);
+ $this->assertEqual($i,27);
+ }
+
+
+ function testValidThreeOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertFalse(utf8_bad_identify($str,$i));
+ $this->assertNull($i);
+ }
+
+
+ function testInvalidThreeOctetSequenceSecond() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x28\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_SEQINCOMPLETE);
+ $this->assertEqual($i,27);
+ }
+
+ function testInvalidThreeOctetSequenceThird() {
+ $str = "Iñtërnâtiônàlizætiøn\xe2\x82\x28Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_SEQINCOMPLETE);
+ $this->assertEqual($i,28);
+ }
+
+ function testValidFourOctetId() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x90\x8c\xbcIñtërnâtiônàlizætiøn";
+ $this->assertFalse(utf8_bad_identify($str,$i));
+ $this->assertNull($i);
+ }
+
+ function testInvalidFourOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf0\x28\x8c\xbcIñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_SEQINCOMPLETE);
+ $this->assertEqual($i,27);
+ }
+
+ function testInvalidFiveOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xf8\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_5OCTET);
+ $this->assertEqual($i,27);
+ }
+
+ function testInvalidSixOctetSequence() {
+ $str = "Iñtërnâtiônàlizætiøn\xfc\xa1\xa1\xa1\xa1\xa1Iñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_bad_identify($str,$i),UTF8_BAD_6OCTET);
+ $this->assertEqual($i,27);
+ }
+
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new GroupTest('utf8_bad');
+ $test->addTestCase(new test_utf8_bad_find());
+ $test->addTestCase(new test_utf8_bad_findall());
+ $test->addTestCase(new test_utf8_bad_strip());
+ $test->addTestCase(new test_utf8_bad_replace());
+ $test->addTestCase(new test_utf8_bad_identify());
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_ord.test.php,v 1.1 2006/03/26 22:26:16 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/ord.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_ord extends UnitTestCase {
+
+ function test_utf8_ord() {
+ $this->UnitTestCase('utf8_ord()');
+ }
+
+ function testEmptyStr() {
+ $str = '';
+ $this->assertEqual(utf8_ord($str),0);
+ }
+
+ function testAsciiChar() {
+ $str = 'a';
+ $this->assertEqual(utf8_ord($str),97);
+ }
+
+ function test2ByteChar() {
+ $str = 'ñ';
+ $this->assertEqual(utf8_ord($str),241);
+ }
+
+ function test3ByteChar() {
+ $str = '₧';
+ $this->assertEqual(utf8_ord($str),8359);
+ }
+
+ function test4ByteChar() {
+ $str = "\xf0\x90\x8c\xbc";
+ $this->assertEqual(utf8_ord($str),66364);
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_ord();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_position.test.php,v 1.1 2006/09/30 22:49:43 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/utils/position.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_position extends UnitTestCase {
+
+ function test_ascii_char_to_byte() {
+ $str = 'testing';
+ $this->assertIdentical(utf8_byte_position($str, 3), 3);
+ $this->assertIdentical(utf8_byte_position($str, 3, 4), array(3,4));
+ $this->assertIdentical(utf8_byte_position($str, -1), 0);
+ $this->assertIdentical(utf8_byte_position($str, 8), 7);
+ }
+
+ function test_multibyte_char_to_byte() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertIdentical(utf8_byte_position($str, 3), 4);
+ $this->assertIdentical(utf8_byte_position($str, 3, 5), array(4,7));
+ $this->assertIdentical(utf8_byte_position($str, -1), 0);
+ $this->assertIdentical(utf8_byte_position($str, 28), 27);
+ }
+
+ // tests for utf8_locate_current_chr & utf8_locate_next_chr
+ function test_singlebyte(){
+ $tests = array();
+
+ // single byte, should return current index
+ $tests[] = array('aaживπά우리をあöä',0,0);
+ $tests[] = array('aaживπά우리をあöä',1,1);
+
+ foreach($tests as $test){
+ $this->assertIdentical(utf8_locate_current_chr($test[0],$test[1]),$test[2]);
+ }
+
+ $tests = array();
+ $tests[] = array('aaживπά우리をあöä',1,1);
+
+ foreach($tests as $test){
+ $this->assertIdentical(utf8_locate_next_chr($test[0],$test[1]),$test[2]);
+ }
+
+ }
+
+ function test_twobyte(){
+ // two byte, should move to boundary, expect even number
+ $tests = array();
+ $tests[] = array('aaживπά우리をあöä',2,2);
+ $tests[] = array('aaживπά우리をあöä',3,2);
+ $tests[] = array('aaживπά우리をあöä',4,4);
+
+ foreach($tests as $test){
+ $this->assertIdentical(utf8_locate_current_chr($test[0],$test[1]),$test[2]);
+ }
+
+ $tests = array();
+ $tests[] = array('aaживπά우리をあöä',2,2);
+ $tests[] = array('aaживπά우리をあöä',3,4);
+ $tests[] = array('aaживπά우리をあöä',4,4);
+
+ foreach($tests as $test){
+ $this->assertIdentical(utf8_locate_next_chr($test[0],$test[1]),$test[2]);
+ }
+ }
+
+ function test_threebyte(){
+ // three byte, should move to boundary 10 or 13
+ $tests = array();
+ $tests[] = array('aaживπά우리をあöä',10,10);
+ $tests[] = array('aaживπά우리をあöä',11,10);
+ $tests[] = array('aaживπά우리をあöä',12,10);
+ $tests[] = array('aaживπά우리をあöä',13,13);
+
+ foreach($tests as $test){
+ $this->assertIdentical(utf8_locate_current_chr($test[0],$test[1]),$test[2]);
+ }
+
+ $tests = array();
+ $tests[] = array('aaживπά우리をあöä',10,10);
+ $tests[] = array('aaживπά우리をあöä',11,13);
+ $tests[] = array('aaживπά우리をあöä',12,13);
+ $tests[] = array('aaживπά우리をあöä',13,13);
+
+ foreach($tests as $test){
+ $this->assertIdentical(utf8_locate_next_chr($test[0],$test[1]),$test[2]);
+ }
+ }
+
+ function test_bounds(){
+ // bounds checking
+ $tests = array();
+ $tests[] = array('aaживπά우리をあöä',-2,0);
+ $tests[] = array('aaживπά우리をあöä',128,29);
+
+ foreach($tests as $test){
+ $this->assertIdentical(utf8_locate_current_chr($test[0],$test[1]),$test[2]);
+ }
+
+ $tests[] = array('aaживπά우리をあöä',-2,0);
+ $tests[] = array('aaживπά우리をあöä',128,29);
+
+ foreach($tests as $test){
+ $this->assertIdentical(utf8_locate_next_chr($test[0],$test[1]),$test[2]);
+ }
+ }
+
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_position();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_specials.test.php,v 1.2 2006/10/17 09:09:13 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/utils/unicode.php';
+require_once UTF8 . '/utils/specials.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_is_word_chars extends UnitTestCase {
+
+ function test_utf8_is_word_chars() {
+ $this->UnitTestCase('test_utf8_is_word_chars()');
+ }
+
+ function testEmptyString() {
+ $this->assertTrue(utf8_is_word_chars(''));
+ }
+
+ function testAllWordChars() {
+ $this->assertTrue(utf8_is_word_chars('HelloWorld'));
+ }
+
+ function testSpecials() {
+ $str = 'Hello ' .
+ chr(0xe0 | (0x2234 >> 12)) .
+ chr(0x80 | ((0x2234 >> 6) & 0x003f)) .
+ chr(0x80 | (0x2234 & 0x003f)) .
+ ' World';
+ $this->assertFalse(utf8_is_word_chars($str));
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strip_specials extends UnitTestCase {
+
+ function test_utf8_strip_specials() {
+ $this->UnitTestCase('test_utf8_strip_specials()');
+ }
+
+ function testEmptyString() {
+ $this->assertEqual(utf8_strip_specials(''),'');
+ }
+
+ function testStrip() {
+ $str = 'Hello ' .
+ chr(0xe0 | (0x2234 >> 12)) .
+ chr(0x80 | ((0x2234 >> 6) & 0x003f)) .
+ chr(0x80 | (0x2234 & 0x003f)) .
+ ' World';
+ $this->assertEqual(utf8_strip_specials($str),'HelloWorld');
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new GroupTest('utf8_ascii');
+ $test->addTestCase(new test_utf8_strip_specials());
+ $test->addTestCase(new test_utf8_is_word_chars());
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_str_ireplace.test.php,v 1.3 2007/08/12 01:20:46 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/str_ireplace.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_str_ireplace extends UnitTestCase {
+
+ function test_utf8_str_ireplace() {
+ $this->UnitTestCase('test_utf8_str_ireplace()');
+ }
+
+ function testReplace() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $replaced = 'Iñtërnâtiônàlisetiøn';
+ $this->assertEqual(utf8_ireplace('lIzÆ','lise',$str),$replaced);
+ }
+
+ function testReplaceNoMatch() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $replaced = 'Iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_ireplace('foo','bar',$str),$replaced);
+ }
+
+ function testEmptyString() {
+ $str = '';
+ $replaced = '';
+ $this->assertEqual(utf8_ireplace('foo','bar',$str),$replaced);
+ }
+
+ function testEmptySearch() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $replaced = 'Iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_ireplace('','x',$str),$replaced);
+ }
+
+ function testReplaceCount() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $replaced = 'IñtërXâtiôXàlizætiøn';
+ $this->assertEqual(utf8_ireplace('n','X',$str,2),$replaced);
+ }
+
+ function testReplaceDifferentSearchReplaceLength() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $replaced = 'IñtërXXXâtiôXXXàlizætiøXXX';
+ $this->assertEqual(utf8_ireplace('n','XXX',$str),$replaced);
+ }
+
+ function testReplaceArrayAsciiSearch() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $replaced = 'Iñyërxâyiôxàlizæyiøx';
+ $this->assertEqual(
+ utf8_ireplace(
+ array('n','t'),
+ array('x','y'),
+ $str
+ ),$replaced);
+ }
+
+ function testReplaceArrayUTF8Search() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $replaced = 'I?tërnâti??nàliz????ti???n';
+ $this->assertEqual(
+ utf8_ireplace(
+ array('Ñ','ô','ø','Æ'),
+ array('?','??','???','????'),
+ $str
+ ),$replaced);
+ }
+
+ function testReplaceArrayStringReplace() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $replaced = 'I?tërnâti?nàliz?ti?n';
+ $this->assertEqual(
+ utf8_ireplace(
+ array('Ñ','ô','ø','Æ'),
+ '?',
+ $str
+ ),$replaced);
+ }
+
+ function testReplaceArraySingleArrayReplace() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $replaced = 'I?tërnâtinàliztin';
+ $this->assertEqual(
+ utf8_ireplace(
+ array('Ñ','ô','ø','Æ'),
+ array('?'),
+ $str
+ ),$replaced);
+ }
+
+ function testReplaceLinefeed() {
+ $str = "Iñtërnâti\nônàlizætiøn";
+ $replaced = "Iñtërnâti\nônàlisetiøn";
+ $this->assertEqual(utf8_ireplace('lIzÆ','lise',$str),$replaced);
+ }
+
+ function testReplaceLinefeedSearch() {
+ $str = "Iñtërnâtiônàli\nzætiøn";
+ $replaced = "Iñtërnâtiônàlisetiøn";
+ $this->assertEqual(utf8_ireplace("lI\nzÆ",'lise',$str),$replaced);
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = & new test_utf8_str_ireplace();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_str_pad.test.php,v 1.1 2006/09/03 09:25:13 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/str_pad.php';
+
+//--------------------------------------------------------------------
+/**
+* @author Oliver Saunders <oliver (a) osinternetservices.com>
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_str_pad extends UnitTestCase {
+ public function test(){
+ $toPad = '<IñtërnëT>'; // 10 characters
+ $padding = 'ø__'; // 4 characters
+
+ $this->assertEqual(utf8_str_pad($toPad, 20), $toPad . ' ');
+ $this->assertEqual(utf8_str_pad($toPad, 20, ' ', STR_PAD_LEFT), ' ' . $toPad);
+ $this->assertEqual(utf8_str_pad($toPad, 20, ' ', STR_PAD_BOTH), ' ' . $toPad . ' ');
+
+ $this->assertEqual(utf8_str_pad($toPad, 10), $toPad);
+ $this->assertEqual(str_pad('5char', 4), '5char'); // str_pos won't truncate input string
+ $this->assertEqual(utf8_str_pad($toPad, 8), $toPad);
+
+ $this->assertEqual(utf8_str_pad($toPad, 20, $padding, STR_PAD_RIGHT), $toPad . 'ø__ø__ø__ø');
+ $this->assertEqual(utf8_str_pad($toPad, 20, $padding, STR_PAD_LEFT), 'ø__ø__ø__ø' . $toPad);
+ $this->assertEqual(utf8_str_pad($toPad, 20, $padding, STR_PAD_BOTH), 'ø__ø_' . $toPad . 'ø__ø_');
+ }
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_str_pad ();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_str_split.test.php,v 1.2 2006/02/25 14:52:18 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/str_split.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_str_split extends UnitTestCase {
+
+ function test_utf8_str_split() {
+ $this->UnitTestCase('utf8_str_split()');
+ }
+
+ function testSplitOneChar() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $array = array(
+ 'I','ñ','t','ë','r','n','â','t','i','ô','n','à','l','i',
+ 'z','æ','t','i','ø','n',
+ );
+ $this->assertEqual(utf8_str_split($str),$array);
+ }
+
+ function testSplitFiveChars() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $array = array(
+ 'Iñtër','nâtiô','nàliz','ætiøn',
+ );
+ $this->assertEqual(utf8_str_split($str,5),$array);
+ }
+
+ function testSplitSixChars() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $array = array(
+ 'Iñtërn','âtiônà', 'lizæti','øn',
+ );
+ $this->assertEqual(utf8_str_split($str,6),$array);
+ }
+
+ function testSplitLong() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $array = array(
+ 'Iñtërnâtiônàlizætiøn',
+ );
+ $this->assertEqual(utf8_str_split($str,40),$array);
+ }
+
+ function testSplitNewline() {
+ $str = "Iñtërn\nâtiônàl\nizætiøn\n";
+ $array = array(
+ 'I','ñ','t','ë','r','n',"\n",'â','t','i','ô','n','à','l',"\n",'i',
+ 'z','æ','t','i','ø','n',"\n",
+ );
+ $this->assertEqual(utf8_str_split($str),$array);
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_str_split();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_strcasecmp.test.php,v 1.2 2006/02/25 14:52:18 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/strcasecmp.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strcasecmp extends UnitTestCase {
+
+ function test_utf8_strcasecmp () {
+ $this->UnitTestCase('test_utf8_strcasecmp()');
+ }
+
+ function testCompareEqual() {
+ $strX = 'iñtërnâtiônàlizætiøn';
+ $strY = 'IÑTËRNÂTIÔNÀLIZÆTIØN';
+ $this->assertEqual(utf8_strcasecmp($strX,$strY),0);
+ }
+
+
+ function testLess() {
+ $strX = 'iñtërnâtiônàlizætiøn';
+ $strY = 'IÑTËRNÂTIÔÀLIZÆTIØN';
+ $this->assertTrue(utf8_strcasecmp($strX,$strY) < 0);
+ }
+
+ function testGreater() {
+ $strX = 'iñtërnâtiôàlizætiøn';
+ $strY = 'IÑTËRNÂTIÔNÀLIZÆTIØN';
+ $this->assertTrue(utf8_strcasecmp($strX,$strY) > 0);
+ }
+
+ function testEmptyX() {
+ $strX = '';
+ $strY = 'IÑTËRNÂTIÔNÀLIZÆTIØN';
+ $this->assertTrue(utf8_strcasecmp($strX,$strY) < 0);
+ }
+
+ function testEmptyY() {
+ $strX = 'iñtërnâtiôàlizætiøn';
+ $strY = '';
+ $this->assertTrue(utf8_strcasecmp($strX,$strY) > 0);
+ }
+
+ function testEmptyBoth() {
+ $strX = '';
+ $strY = '';
+ $this->assertTrue(utf8_strcasecmp($strX,$strY) == 0);
+ }
+
+ function testLinefeed() {
+ $strX = "iñtërnâtiôn\nàlizætiøn";
+ $strY = "IÑTËRNÂTIÔN\nÀLIZÆTIØN";
+ $this->assertTrue(utf8_strcasecmp($strX,$strY) == 0);
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_strcasecmp ();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_strcspn.test.php,v 1.2 2006/02/25 14:52:18 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/strcspn.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strcspn extends UnitTestCase {
+
+ function test_utf8_strcspn () {
+ $this->UnitTestCase('test_utf8_strcspn()');
+ }
+
+ function testNoMatchSingleByteSearch() {
+ $str = 'iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_strcspn($str,'t'),2);
+ }
+
+ function testNoMatchMultiByteSearch() {
+ $str = 'iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_strcspn($str,'â'),6);
+ }
+
+ function testCompareStrspn() {
+ $str = 'aeioustr';
+ $this->assertEqual(utf8_strcspn($str,'tr'),strcspn($str,'tr'));
+ }
+
+ function testMatchAscii() {
+ $str = 'internationalization';
+ $this->assertEqual(utf8_strcspn($str,'a'),strcspn($str,'a'));
+ }
+
+ function testLinefeed() {
+ $str = "i\nñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_strcspn($str,'t'),3);
+ }
+
+ function testLinefeedMask() {
+ $str = "i\nñtërnâtiônàlizætiøn";
+ $this->assertEqual(utf8_strcspn($str,"\n"),1);
+ }
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_strcspn ();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_stristr.test.php,v 1.2 2006/02/25 14:52:18 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/stristr.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_stristr extends UnitTestCase {
+
+ function test_utf8_stristr () {
+ $this->UnitTestCase('test_utf8_stristr()');
+ }
+
+ function testSubstr() {
+ $str = 'iñtërnâtiônàlizætiøn';
+ $search = 'NÂT';
+ $this->assertEqual(utf8_stristr($str,$search),'nâtiônàlizætiøn');
+ }
+
+ function testSubstrNoMatch() {
+ $str = 'iñtërnâtiônàlizætiøn';
+ $search = 'foo';
+ $this->assertFalse(utf8_stristr($str,$search));
+ }
+
+ function testEmptySearch() {
+ $str = 'iñtërnâtiônàlizætiøn';
+ $search = '';
+ $this->assertEqual(utf8_stristr($str,$search),'iñtërnâtiônàlizætiøn');
+ }
+
+ function testEmptyStr() {
+ $str = '';
+ $search = 'NÂT';
+ $this->assertFalse(utf8_stristr($str,$search));
+ }
+
+ function testEmptyBoth() {
+ $str = '';
+ $search = '';
+ $this->assertEqual(utf8_stristr($str,$search),'');
+ }
+
+ function testLinefeedStr() {
+ $str = "iñt\nërnâtiônàlizætiøn";
+ $search = 'NÂT';
+ $this->assertEqual(utf8_stristr($str,$search),'nâtiônàlizætiøn');
+ }
+
+ function testLinefeedBoth() {
+ $str = "iñtërn\nâtiônàlizætiøn";
+ $search = "N\nÂT";
+ $this->assertEqual(utf8_stristr($str,$search),"n\nâtiônàlizætiøn");
+ }
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_stristr ();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_strlen.test.php,v 1.2 2006/02/24 23:33:10 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strlen extends UnitTestCase {
+
+ function test_utf8_strlen() {
+ $this->UnitTestCase('utf8_strlen()');
+ }
+
+ function testUtf8() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_strlen($str),20);
+ }
+
+ function testUtf8Invalid() {
+ $str = "Iñtërnâtiôn\xe9àlizætiøn";
+ $this->assertEqual(utf8_strlen($str),20);
+ }
+
+ function testAscii() {
+ $str = 'ABC 123';
+ $this->assertEqual(utf8_strlen($str),7);
+ }
+
+ function testEmptyStr() {
+ $str = '';
+ $this->assertEqual(utf8_strlen($str),0);
+ }
+
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_strlen();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_strpos.test.php,v 1.2 2006/02/24 23:33:10 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strpos extends UnitTestCase {
+
+ function test_utf8_strpos() {
+ $this->UnitTestCase('utf8_strpos()');
+ }
+
+ function testUtf8() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_strpos($str,'â'),6);
+ }
+
+ function testUtf8Offset() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_strpos($str,'n',11),19);
+ }
+
+ function testUtf8Invalid() {
+ $str = "Iñtërnâtiôn\xe9àlizætiøn";
+ $this->assertEqual(utf8_strpos($str,'æ'),15);
+ }
+
+ function testAscii() {
+ $str = 'ABC 123';
+ $this->assertEqual(utf8_strpos($str,'B'),1);
+ }
+
+ function testVsStrpos() {
+ $str = 'ABC 123 ABC';
+ $this->assertEqual(utf8_strpos($str,'B',3),strpos($str,'B',3));
+ }
+
+ function testEmptyStr() {
+ $str = '';
+ $this->assertFalse(utf8_strpos($str,'x'));
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_strpos();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_strrev.test.php,v 1.2 2006/02/25 14:52:18 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/strrev.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strrev extends UnitTestCase {
+
+ function test_utf8_strrev() {
+ $this->UnitTestCase('utf8_strrev()');
+ }
+
+ function testReverse() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $rev = 'nøitæzilànôitânrëtñI';
+ $this->assertEqual(utf8_strrev($str),$rev);
+ }
+
+ function testEmptyStr() {
+ $str = '';
+ $rev = '';
+ $this->assertEqual(utf8_strrev($str),$rev);
+ }
+
+ function testLinefeed() {
+ $str = "Iñtërnâtiôn\nàlizætiøn";
+ $rev = "nøitæzilà\nnôitânrëtñI";
+ $this->assertEqual(utf8_strrev($str),$rev);
+ }
+
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_strrev();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_strrpos.test.php,v 1.3 2006/02/24 23:33:10 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strrpos extends UnitTestCase {
+
+ function test_utf8_strrpos() {
+ $this->UnitTestCase('utf8_strrpos()');
+ }
+
+ function testUtf8() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_strrpos($str,'i'),17);
+ }
+
+ function testUtf8Offset() {
+ $str = 'Iñtërnâtiônàlizætiøn';
+ $this->assertEqual(utf8_strrpos($str,'n',11),19);
+ }
+
+ function testUtf8Invalid() {
+ $str = "Iñtërnâtiôn\xe9àlizætiøn";
+ $this->assertEqual(utf8_strrpos($str,'æ'),15);
+ }
+
+ function testAscii() {
+ $str = 'ABC ABC';
+ $this->assertEqual(utf8_strrpos($str,'B'),5);
+ }
+
+ function testVsStrpos() {
+ $str = 'ABC 123 ABC';
+ $this->assertEqual(utf8_strrpos($str,'B'),strrpos($str,'B'));
+ }
+
+ function testEmptyStr() {
+ $str = '';
+ $this->assertFalse(utf8_strrpos($str,'x'));
+ }
+
+ function testLinefeed() {
+ $str = "Iñtërnâtiônàlizætiø\nn";
+ $this->assertEqual(utf8_strrpos($str,'i'),17);
+ }
+
+ function testLinefeedSearch() {
+ $str = "Iñtërnâtiônàlizætiø\nn";
+ $this->assertEqual(utf8_strrpos($str,"\n"),19);
+ }
+}
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+if (!defined('TEST_RUNNING')) {
+ define('TEST_RUNNING', true);
+ $test = &new test_utf8_strrpos();
+ $reporter = & getTestReporter();
+ $test->run($reporter);
+}
--- /dev/null
+<?php
+/**
+* @version $Id: utf8_strspn.test.php,v 1.2 2006/02/25 14:52:18 harryf Exp $
+* @package utf8
+* @subpackage Tests
+*/
+
+//--------------------------------------------------------------------
+/**
+* Includes
+* @package utf8
+* @subpackage Tests
+*/
+require_once(dirname(__FILE__).'/../config.php');
+require_once UTF8 . '/strspn.php';
+
+//--------------------------------------------------------------------
+/**
+* @package utf8
+* @subpackage Tests
+*/
+class test_utf8_strspn extends UnitTestCase {
+
+ function test_utf8_strspn () {
+ $this->UnitTestCase('test_utf8_strspn()');
+ }
+
+ function testMatch() {
+ $str = 'iñtërnâtiônàlizætiøn';
+ $this->a