sebastiansulinski/smart-quotes

智能引号替换工具包

v2.1.1 2024-07-09 14:45 UTC

This package is auto-updated.

Last update: 2024-09-09 15:06:04 UTC


README

该工具包将所有不规则 - 微软版本的单一和双引号替换为简单的 - ASCII 类型的引号。

要求

从版本 1.3.0 开始,该包需要 PHP 7.1 或更高版本。请使用版本 1.2.0 为 PHP 7.0 或版本 1.0.5 为更早版本。

使用示例

有两种实现方式 - 一种是将引号转换为 UTF-8 格式的内容,另一种也是将引号转换为 ASCII 格式的内容(英镑符号(£)除外,它也能正确返回)。

use SSD\SmartQuotes\Utf8CharacterSet;
use SSD\SmartQuotes\Factory as SmartQuotesFactory;

$string = "“Contrary to ‘popular belief’, Lorem Ipsum is not simply ‘random text’. The cost in Sterling is £20.00”";

// UTF-8 implementation
echo SmartQuotesFactory::filter(new Utf8CharacterSet, $string);

// ASCII implementation
echo SmartQuotesFactory::filter(new AsciiCharacterSet, $string);

// both return:
// "Contrary to 'popular belief', Lorem Ipsum is not simply 'random text'. The cost in Sterling is £20.00"