[//]: # (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-ca
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
更新日志v1.0.2: 1.修复了关联上下文的问题,使对话更加连贯。 2.改进了登录界面,提升了用户体验。 3.新增了意间绘画模型,让你可以进行更多创作。 4.增加了全新的会员中心,提供更多个性化服务。 5.引入了套餐付费功能,方便用户选择适合自己的服务。 6.优化了绘画广场,让你展示作品更加出色。 7.新增了默认对话应用,方便快速启动聊天。 8.改进了对话界面的用户界面,使交流更加便捷。 9.修复了回复消息卡顿的问题,提高了响应速度。 10.新增思维导图生成功能,帮助你更好地整理思路。 v1.0.1: 1.新增了app模型应用,增加了更多实用功能。 2.引入了mj绘画功能,拓展了创作可能性。 3.优化了绘画广场,让你与更多人分享作品。 4.升级至gpt4.0版本,提供更强大的聊天能力。 5.新增自定义对话地址功能,满足个性化需求。 6.优化了手机模板,提升了移动端的使用体验。 v1.0.0: 1.新增gpt聊天模型,实现更智能的对话交流。 2.优化了多条消息发送,使对话更加流畅。 3.改进了自适应手机端的表现,适配性更强。 4.增加了应用中
资源推荐
资源详情
资源评论
收起资源包目录
ChatGPT网站源码全新AI系统支持GPT-4、AI绘画功能,持续更新 (2000个子文件)
COMMITMENT 2KB
style-08734573.css 598KB
index.css 327KB
htmlDescriptor.css 3KB
inline-demo.css 1KB
style-guide.css 1KB
options-boxes.css 515B
badges.css 431B
pages.css 325B
index.css 247B
utilities.css 189B
layout.css 187B
phpunit.xml.dist 959B
phpunit.xml.dist 559B
Migration.change.template.php.dist 538B
Seed.template.php.dist 357B
Migration.up_down.template.php.dist 213B
phpstan.neon.dist 124B
安装说明.docx 439KB
搭建教程.docx 61KB
.editorconfig 337B
.env 86B
fontawesome-webfont-7bfcab6d.eot 162KB
hiddeninput.exe 9KB
loading.gif 6KB
.gitattributes 70B
.gitattributes 49B
.gitignore 158B
.gitignore 127B
.gitignore 74B
.gitignore 52B
.gitignore 43B
.gitignore 27B
nginx.htaccess 113B
.htaccess 13B
.htaccess 0B
index.html 14KB
index.html 480B
favicon.ico 4KB
favicon.ico 4KB
info.ini 219B
info.ini 217B
info.ini 208B
info.ini 195B
info.ini 188B
info.ini 155B
userb1c0a99d22a4a41f57a3fa567c64684fc669c26b.jpg 40KB
3.jpg 31KB
6.jpg 31KB
1.jpg 30KB
7.jpg 30KB
8.jpg 29KB
2.jpg 29KB
4.jpg 28KB
5.jpg 27KB
bg-95f82371.jpg 4KB
index-e2b8ae74.js 1.15MB
vue-8508a9fb.js 1.08MB
index.js 1.02MB
echarts-02f2616f.js 1004KB
message-7d70fa8d.js 921KB
mind-0bc0100a.js 438KB
index-f8995590.js 156KB
index-3223385b.js 106KB
info-f6b3512d.js 105KB
index-48aac435.js 99KB
index-44e0a1fb.js 93KB
index-4bdb6db9.js 69KB
pay-8bfba4ef.js 55KB
index-f066f291.js 54KB
index-837a053d.js 41KB
index-44855ea2.js 39KB
sql-62feda9f.js 36KB
design-7abaabc9.js 36KB
router-efa663bc.js 35KB
css-ae0ae1d0.js 26KB
index-1168b2ba.js 25KB
stylus-2d29a832.js 25KB
dashboard-fe6c00e7.js 24KB
clike-c6a401fb.js 22KB
index-354ca45c.js 20KB
javascript-da64953c.js 17KB
index-c61f7884.js 16KB
profile-19e3339c.js 13KB
config-450accaf.js 13KB
crud-e2e89af5.js 13KB
index-c38c0273.js 12KB
login-8db08d68.js 12KB
idl-91cb7788.js 11KB
draw-0af92c81.js 11KB
chat-46a1ed1d.js 11KB
index-a15c97d5.js 11KB
clojure-46c215dd.js 11KB
goodsInfo-8c800cee.js 10KB
gherkin-0efe02ac.js 10KB
add.vue_vue_type_script_setup_true_lang-545fb4eb.js 10KB
perl-a9455719.js 10KB
sas-4096b960.js 9KB
crud-a364cc22.js 9KB
popupForm-8de1f1b7.js 9KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
XD资源
- 粉丝: 43
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 云平台VPC.vsdx
- PIPE物理层接口规范:PCIe SATA USB3.1 DisplayPort 和 Converged IO 架构
- SparkSQL进阶操作相关数据
- java制作的小游戏,作为巩固java知识之用.zip
- Java语言写的围棋小游戏 半成品A Go game written in golang(Semi-finished).zip
- 基于Java-swing的俄罗斯方块游戏:源码+答辩文档+PPT.zip
- florr map详细版
- shiahdifhiahfiqefiwhfi weifwijfiwqufiqweefijeq0jfe
- registry-2.8.3<arm/amd>二进制文件
- Kotlin接口与抽象类详解及其应用
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功