rny/zhconverter

convert between Simplified Chinese(zh-Hans) and Traditional Chinese(zh-Hant)

Maintainers

Package info

github.com/rny/ZhConverter

pkg:composer/rny/zhconverter

Statistics

Installs: 35 573

Dependents: 0

Suggesters: 0

Stars: 4

Open Issues: 0

1.0.0 2016-10-30 16:09 UTC

This package is not auto-updated.

Last update: 2026-03-01 03:53:24 UTC


README

Build Status

ZhConverter is a simple PHP library to convert between Simplified Chinese(zh-Hans) and Traditional Chinese(zh-Hant). ZhConverter is using WikiMedia ZhConverter.php as convertion table.

For those rquire better convertion quality, the C++ project OpenCC may be considered.

Highlights

  • One line code to do the convertion
  • Composer ready, PSR-4 compatible.
  • PHPUnit tested.

Install

Install ZhConverter using Composer.

$ composer require rny/zhconverter

Usage

use Rny\ZhConverter\ZhConverter;

$text = ZhConverter::zh2hant($text);
$text = ZhConverter::zh2hans($text);
$text = ZhConverter::zh2TW($text);
$text = ZhConverter::zh2HK($text);
$text = ZhConverter::zh2CN($text);
$text = \Rny\ZhConverter\ZhConverter::zh2hant($text);
$text = \Rny\ZhConverter\ZhConverter::zh2hans($text);
$text = \Rny\ZhConverter\ZhConverter::zh2TW($text);
$text = \Rny\ZhConverter\ZhConverter::zh2HK($text);
$text = \Rny\ZhConverter\ZhConverter::zh2CN($text);

Testing

$ composer test