diff options
author | friendica <info@friendica.com> | 2014-01-18 23:49:39 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-01-18 23:49:39 -0800 |
commit | 724ad4505628d493b43b4f585512d67dc0b4ee76 (patch) | |
tree | 4fb920a79e3dff961a6301ec56ec9f40e91f6af3 /library/ajaxchat/chat/lib/class/AJAXChatString.php | |
parent | 3f7032e542e3c451507fc9266ab3536155c8190f (diff) | |
download | volse-hubzilla-724ad4505628d493b43b4f585512d67dc0b4ee76.tar.gz volse-hubzilla-724ad4505628d493b43b4f585512d67dc0b4ee76.tar.bz2 volse-hubzilla-724ad4505628d493b43b4f585512d67dc0b4ee76.zip |
add ajaxchat library - needs a lot of integration work to handle decentralisation (e.g. chatroom@website) and zotid w/permissions (e.g. ACL controlled chatrooms); we can also rip out a lot of stuff we don't need.
Diffstat (limited to 'library/ajaxchat/chat/lib/class/AJAXChatString.php')
-rw-r--r-- | library/ajaxchat/chat/lib/class/AJAXChatString.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/library/ajaxchat/chat/lib/class/AJAXChatString.php b/library/ajaxchat/chat/lib/class/AJAXChatString.php new file mode 100644 index 000000000..8997da5ea --- /dev/null +++ b/library/ajaxchat/chat/lib/class/AJAXChatString.php @@ -0,0 +1,37 @@ +<?php +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license Modified MIT License + * @link https://blueimp.net/ajax/ + */ + +// Class to provide multibyte enabled string methods +class AJAXChatString { + + public static function subString($str, $start=0, $length=null, $encoding='UTF-8') { + if($length === null) { + $length = AJAXChatString::stringLength($str); + } + if(function_exists('mb_substr')) { + return mb_substr($str, $start, $length, $encoding); + } else if(function_exists('iconv_substr')) { + return iconv_substr($str, $start, $length, $encoding); + } else { + return substr($str, $start, $length); + } + } + + public static function stringLength($str, $encoding='UTF-8') { + if(function_exists('mb_strlen')) { + return mb_strlen($str, $encoding); + } else if(function_exists('iconv_strlen')) { + return iconv_strlen($str, $encoding); + } else { + return strlen($str); + } + } + +} +?>
\ No newline at end of file |