lpinyin
2.0.3, released 6 years ago by an unverified publisher
Converts Chinese characters to Pinyin with support for multiple formats and simplified/traditional script.
WASM-ready
What it does
lpinyin converts Chinese characters into Pinyin representations with options for tone marks, tone numbers, or without tones. It handles polyphonic words (heteronyms) using dictionary lookups, converts between simplified and traditional Chinese characters, and allows custom user dictionaries.
AI-written summary of version 2.0.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- Sorting or indexing Chinese contacts, lists, or city names alphabetically by Pinyin or initials
- Implementing Pinyin-based search or auto-complete for Chinese text
- Converting between simplified and traditional Chinese characters
Skip it when
- Working exclusively with non-Chinese text or languages that do not require romanization
Strengths
- No external dependencies, enabling lightweight pure-Dart cross-platform use
- Supports multiple Pinyin formats including tone marks, no tones, and acronym initials
- Allows adding custom dictionaries for Pinyin, polyphonic words, and traditional characters
Weaknesses
- Changelog entries provide minimal detail regarding bug fixes and version updates
- Requires manual addition of custom dictionary mappings if uncommon polyphonic contexts are not covered
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:lpinyin/lpinyin.dart';
void main() {
String text = '天府广场';
// Get short Pinyin (initials)
String initials = PinyinHelper.getShortPinyin(text); // tfgc
// Convert to Pinyin without tones
String pinyin = PinyinHelper.getPinyinE(
text,
separator: ' ',
format: PinyinFormat.WITHOUT_TONE,
); // tian fu guang chang
}Alternatives
Packages that do the same job and could replace lpinyin.
Works with
Packages commonly used together with lpinyin: ones it builds on, ones built on it, and its own family.