[//]: # (AUTO-GENERATED BY "PHP README Helper": base file -> docs/base.md)
[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
[![Build Status](https://github.com/voku/portable-utf8/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/voku/portable-utf8/actions)
[![Build status](https://ci.appveyor.com/api/projects/status/gnejjnk7qplr7f5t/branch/master?svg=true)](https://ci.appveyor.com/project/voku/portable-utf8/branch/master)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fvoku%2Fportable-utf8.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fvoku%2Fportable-utf8?ref=badge_shield)
[![codecov.io](https://codecov.io/github/voku/portable-utf8/coverage.svg?branch=master)](https://codecov.io/github/voku/portable-utf8?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/997c9bb10d1c4791967bdf2e42013e8e)](https://www.codacy.com/app/voku/portable-utf8)
[![Latest Stable Version](https://poser.pugx.org/voku/portable-utf8/v/stable)](https://packagist.org/packages/voku/portable-utf8)
[![Total Downloads](https://poser.pugx.org/voku/portable-utf8/downloads)](https://packagist.org/packages/voku/portable-utf8)
[![License](https://poser.pugx.org/voku/portable-utf8/license)](https://packagist.org/packages/voku/portable-utf8)
[![Donate to this project using PayPal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.me/moelleken)
[![Donate to this project using Patreon](https://img.shields.io/badge/patreon-donate-yellow.svg)](https://www.patreon.com/voku)
# 🉑 Portable UTF-8
## Description
It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your server.
The benefit of Portable UTF-8 is that it is easy to use, easy to bundle. This library will also
auto-detect your server environment and will use the installed php-extensions if they are available,
so you will have the best possible performance.
As a fallback we will use Symfony Polyfills, if needed. (https://github.com/symfony/polyfill)
The project based on ...
+ Hamid Sarfraz's work - [portable-utf8](http://pageconfig.com/attachments/portable-utf8.php)
+ Nicolas Grekas's work - [tchwork/utf8](https://github.com/tchwork/utf8)
+ Behat's work - [Behat/Transliterator](https://github.com/Behat/Transliterator)
+ Sebastián Grignoli's work - [neitanod/forceutf8](https://github.com/neitanod/forceutf8)
+ Ivan Enderlin's work - [hoaproject/Ustring](https://github.com/hoaproject/Ustring)
+ and many cherry-picks from "GitHub"-gists and "Stack Overflow"-snippets ...
## Demo
Here you can test some basic functions from this library and you can compare some results with the native php function results.
+ [encoder.suckup.de](https://encoder.suckup.de/)
## Index
* [Alternative](#alternative)
* [Install](#install-portable-utf-8-via-composer-require)
* [Why Portable UTF-8?](#why-portable-utf-8)
* [Requirements and Recommendations](#requirements-and-recommendations)
* [Warning](#warning)
* [Usage](#usage)
* [Class methods](#class-methods)
* [Unit Test](#unit-test)
* [License and Copyright](#license-and-copyright)
## Alternative
If you like a more Object Oriented Way to edit strings, then you can take a look at [voku/Stringy](https://github.com/voku/Stringy), it's a fork of "danielstjules/Stringy" but it used the "Portable UTF-8"-Class and some extra methods.
```php
// Standard library
strtoupper('fòôbàř'); // 'FòôBàř'
strlen('fòôbàř'); // 10
// mbstring
// WARNING: if you don't use a polyfill like "Portable UTF-8", you need to install the php-extension "mbstring" on your server
mb_strtoupper('fòôbàř'); // 'FÒÔBÀŘ'
mb_strlen('fòôbàř'); // '6'
// Portable UTF-8
use voku\helper\UTF8;
UTF8::strtoupper('fòôbàř'); // 'FÒÔBÀŘ'
UTF8::strlen('fòôbàř'); // '6'
// voku/Stringy
use Stringy\Stringy as S;
$stringy = S::create('fòôbàř');
$stringy->toUpperCase(); // 'FÒÔBÀŘ'
$stringy->length(); // '6'
```
## Install "Portable UTF-8" via "composer require"
```shell
composer require voku/portable-utf8
```
If your project do not need some of the Symfony polyfills please use the `replace` section of your `composer.json`.
This removes any overhead from these polyfills as they are no longer part of your project. e.g.:
```json
{
"replace": {
"symfony/polyfill-php72": "1.99",
"symfony/polyfill-iconv": "1.99",
"symfony/polyfill-intl-grapheme": "1.99",
"symfony/polyfill-intl-normalizer": "1.99",
"symfony/polyfill-mbstring": "1.99"
}
}
```
## Why Portable UTF-8?[]()
PHP 5 and earlier versions have no native Unicode support. To bridge the gap, there exist several extensions like "mbstring", "iconv" and "intl".
The problem with "mbstring" and others is that most of the time you cannot ensure presence of a specific one on a server. If you rely on one of these, your application is no more portable. This problem gets even severe for open source applications that have to run on different servers with different configurations. Considering these, I decided to write a library:
## Requirements and Recommendations
* No extensions are required to run this library. Portable UTF-8 only needs PCRE library that is available by default since PHP 4.2.0 and cannot be disabled since PHP 5.3.0. "\u" modifier support in PCRE for UTF-8 handling is not a must.
* PHP 5.3 is the minimum requirement, and all later versions are fine with Portable UTF-8.
* PHP 7.0 is the minimum requirement since version 4.0 of Portable UTF-8, otherwise composer will install an older version
* PHP 8.0 support is also available and will adapt the behaviours of the native functions.
* To speed up string handling, it is recommended that you have "mbstring" or "iconv" available on your server, as well as the latest version of PCRE library
* Although Portable UTF-8 is easy to use; moving from native API to Portable UTF-8 may not be straight-forward for everyone. It is highly recommended that you do not update your scripts to include Portable UTF-8 or replace or change anything before you first know the reason and consequences. Most of the time, some native function may be all what you need.
* There is also a shim for "mbstring", "iconv" and "intl", so you can use it also on shared webspace.
## Usage
Example 1: UTF8::cleanup()
```php
echo UTF8::cleanup('�Düsseldorf�');
// will output:
// Düsseldorf
```
Example 2: UTF8::strlen()
```php
$string = 'string <strong>with utf-8 chars åèä</strong> - doo-bee doo-bee dooh';
echo strlen($string) . "\n<br />";
echo UTF8::strlen($string) . "\n<br />";
// will output:
// 70
// 67
$string_test1 = strip_tags($string);
$string_test2 = UTF8::strip_tags($string);
echo strlen($string_test1) . "\n<br />";
echo UTF8::strlen($string_test2) . "\n<br />";
// will output:
// 53
// 50
```
Example 3: UTF8::fix_utf8()
```php
echo UTF8::fix_utf8('Düsseldorf');
echo UTF8::fix_utf8('ä');
// will output:
// Düsseldorf
// ä
```
# Portable UTF-8 | API
The API from the "UTF8"-Class is written as small static methods that will match the default PHP-API.
## Class methods
<p id="voku-php-readme-class-methods"></p><table><tr><td><a href="#accessstring-str-int-pos-string-encoding-string">access</a>
</td><td><a href="#add_bom_to_stringstring-str-non-empty-string">add_bom_to_string</a>
</td><td><a href="#array_change_key_casearray-array-int-case-string-encoding-string">array_change_key_case</a>
</td><td><a href="#betweenstring-str-string-start-string-end-int-offset-string-encoding-string">between</a>
</td></tr><tr><td><a href="#binary_to_strstring-bin-string">binary_to_str</a>
</td><td><a href="#bom-non-empty-string">bom</a>
</td><td><a href="#callbackcallablestring--string-c
没有合适的资源?快使用搜索试试~ 我知道了~
bbs源码插件和源码打包
共2000个文件
js:666个
php:342个
png:265个
需积分: 0 2 下载量 2 浏览量
2023-08-31
19:47:48
上传
评论
收藏 26.97MB ZIP 举报
温馨提示
qq.xmyay.com
资源推荐
资源详情
资源评论
收起资源包目录
bbs源码插件和源码打包 (2000个子文件)
20230621100059 80KB
style.css 525KB
mdui.css 416KB
oneui.css 325KB
index.d092f8b7.css 318KB
index.4dc3a78f.css 318KB
mdui.min.css 318KB
argon.css 292KB
app.min.css 271KB
app.min.css 252KB
bootstrap.css 202KB
iconfont.css 169KB
icons.min.css 155KB
bootstrap.min.css 141KB
layui.css 118KB
layui.css 118KB
style.css 117KB
layui.mobile.css 117KB
foxui.css 103KB
index.97465e7b.css 94KB
index.97465e7b.css 94KB
index.97465e7b.css 94KB
admin.css 69KB
index.css 52KB
main.css 47KB
foxui.diy.css 31KB
pcoded-horizontal.min.css 30KB
ambiance.css 26KB
detail.css 22KB
admin.css 20KB
login.css 19KB
fz.min.css 18KB
Global.css 18KB
mobile.css 18KB
layim.css 15KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
encrypt.css 11KB
template.css 10KB
mobile.css 9KB
easyeditor.css 9KB
codemirror.css 9KB
fonticon.css 8KB
laydate.css 7KB
laydate.css 7KB
dataTables.bootstrap4.css 6KB
solarized.css 6KB
mdn-like.css 5KB
layer.css 5KB
style.css 5KB
responsive.bootstrap4.css 5KB
docs.css 4KB
liquibyte.css 4KB
merge.css 4KB
yonce.css 3KB
xq-dark.css 3KB
lint.css 3KB
darcula.css 3KB
lesser-dark.css 3KB
duotone-light.css 3KB
material-palenight.css 3KB
duotone-dark.css 3KB
ttcn.css 3KB
material-darker.css 3KB
material-ocean.css 3KB
pastel-on-dark.css 3KB
shadowfox.css 3KB
tomorrow-night-eighties.css 3KB
ayu-mirage.css 2KB
moxer.css 2KB
material.css 2KB
ayu-dark.css 2KB
oceanic-next.css 2KB
erlang-dark.css 2KB
xq-light.css 2KB
error.css 2KB
twilight.css 2KB
monokai.css 2KB
icecoder.css 2KB
vibrant-ink.css 2KB
mbo.css 2KB
base16-light.css 2KB
nord.css 2KB
base16-dark.css 2KB
login.css 2KB
paraiso-light.css 2KB
paraiso-dark.css 2KB
3024-night.css 2KB
dracula.css 2KB
zenburn.css 2KB
seti.css 2KB
abcdef.css 2KB
3024-day.css 2KB
the-matrix.css 2KB
blackboard.css 2KB
lucario.css 2KB
tern.css 2KB
yeti.css 2KB
midnight.css 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
2201_75516831
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功