zonuexe/stringwidth

测量字符串宽度(支持Unicode东亚模糊宽度)

0.1.1 2015-03-22 18:57 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:37:28 UTC


README

测量字符串宽度(支持Unicode东亚模糊宽度)

安装

composer require 'zonuexe/stringwidth:~0.1.1'

用法

注意:输入字符串必须是UTF-8编码

<?php

\Teto\StringWidth::asSingle('ABC'); //=> 3
\Teto\StringWidth::asDouble('ABC'); //=> 3

\Teto\StringWidth::asSingle('☆☆☆'); //=> 3
\Teto\StringWidth::asDouble('☆☆☆'); //=> 6

\Teto\StringWidth::asSingle('도서관'); //=> 6
\Teto\StringWidth::asDouble('도서관'); //=> 6

版权

src/StringWidth/Tanasinn/*.php代码是由tanasinn/wcwidth.js at e432aeec63452e8c4d1e40e93f5f88f1bc729dca · saitoha/tanasinn派生而来。USAMI Kenta(@zonuexe)将其从JavaScript移植到PHP。

请参阅src/StringWidth/Tanasinn/LICENSE

***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1

The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is tanasinn
The Initial Developer of the Original Code is * Hayaki Saito.
Portions created by the Initial Developer are Copyright (C) 2010 - 2011
the Initial Developer. All Rights Reserved.
***** END LICENSE BLOCK *****

src/StringWidth.php和测试代码遵循Mozilla公共许可证,版本2.0

Copyright (c) 2015 USAMI Kenta

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.