yarri/utf8-cleaner 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yarri/utf8-cleaner

最新稳定版本:v1.1

Composer 安装命令:

composer require yarri/utf8-cleaner

包简介

Removes invalid UTF-8 characters from the given text

README 文档

README

Build Status

Removes invalid UTF-8 byte sequences from the given text.

Utf8Cleaner is inspired by https://stackoverflow.com/questions/1401317/remove-non-utf8-characters-from-string

Usage

Consider you have a string with an illegal UTF-8 byte sequence.

$invalid_char = chr(200).chr(200); // invalid byte sequence for UTF-8
$malformed_text = "Příliš žluťoučk$invalid_char kůň";

$text = \Yarri\Utf8Cleaner::Clean($malformed_text);

By default, each invalid byte sequence is replaced with � (i.e. a black diamond with a white question mark - REPLACEMENT CHARACTER used to replace an unknown, unrecognized or unrepresentable character, U+FFFD).

echo $text; // "Příliš žluťoučk� kůň"

The default replacement can be overridden by an option.

$text = \Yarri\Utf8Cleaner::Clean($malformed_text,["replacement" => "?"]);
// or
$text = \Yarri\Utf8Cleaner::Clean($malformed_text,"?");

echo $text; // "Příliš žluťoučk? kůň"

Installation

The best way how to install Utf8Cleaner is to use the Composer:

composer require yarri/utf8-cleaner

Testing

composer update --dev
./vendor/bin/run_unit_tests test/

License

Utf8Cleaner is free software distributed under the terms of the MIT license

统计信息

  • 总下载量: 4.79k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-07