Skip to content

Commit 14beb33

Browse files
author
燕睿涛
committed
更新readme
1 parent 6df8aab commit 14beb33

File tree

2 files changed

+10
-52
lines changed

2 files changed

+10
-52
lines changed

README.md

+9-51
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,15 @@ echo "最大使用内存【".memory_get_peak_usage(true)."bytes】";
6565
分析下,因为我这个使用的是 fast-cgi 模式,模块初始化的时候已经将拼音汉字相关数据载入内存,所以查询起来很快,不用每次去加载一遍数据
6666

6767
### 使用
68-
这里用了最简洁的方式,用了一个函数 `chinese_to_pinyin(char *str, int flags)`,根据不同的参数,转换为不用的形式
68+
这里用了最简洁的方式,用了一个函数 `pinyin(char *str, int flags)`,根据不同的参数,转换为不用的形式
6969
> PINYIN_NONE 拼音不加音调
7070
> PINYIN_UNICODE 拼音加音调
71+
> PINYIN_ASCII 音标以数字形式
7172
> PINYIN_ISNAME 要转化的内容为名字
72-
> PINYIN_TRIM 简洁模式,去掉所有的标点符号
73-
> PINYIN_FORMAT_EN 将标点符号全转化为英文格式
74-
> PINYIN_FORMAT_CH 将标点符号全转化中文格式
7573
7674
#### PINYIN_NONE 不带音调
7775
```php
78-
print_r(chinese_to_pinyin("你因为穷用盗版的时候至少要知道自己是不对的,这说明你还有救。", PINYIN_NONE));
76+
print_r(pinyin("你因为穷用盗版的时候至少要知道自己是不对的,这说明你还有救。", PINYIN_NONE));
7977
```
8078
输出结果:
8179

@@ -113,49 +111,9 @@ Array
113111
)
114112
```
115113

116-
#### 不带音调和格式化标点符号
114+
#### 带音调
117115
```php
118-
print_r(chinese_to_pinyin("你因为穷用盗版的时候至少要知道自己是不对的,这说明你还有救。", PINYIN_NONE|PINYIN_TRIM));
119-
```
120-
121-
结果如下,可以看出标点符号全过滤掉了
122-
```
123-
Array
124-
(
125-
[0] => ni
126-
[1] => yin
127-
[2] => wei
128-
[3] => qiong
129-
[4] => yong
130-
[5] => dao
131-
[6] => ban
132-
[7] => de
133-
[8] => shi
134-
[9] => hou
135-
[10] => zhi
136-
[11] => shao
137-
[12] => yao
138-
[13] => zhi
139-
[14] => dao
140-
[15] => zi
141-
[16] => ji
142-
[17] => shi
143-
[18] => bu
144-
[19] => dui
145-
[20] => de
146-
[21] => zhe
147-
[22] => shuo
148-
[23] => ming
149-
[24] => ni
150-
[25] => hai
151-
[26] => you
152-
[27] => jiu
153-
)
154-
```
155-
156-
#### 带音调和格式化标点
157-
```php
158-
print_r(chinese_to_pinyin("你因为穷用盗版的时候至少要知道自己是不对的,这说明你还有救。", PINYIN_UNICODE|PINYIN_FORMAT_CH));
116+
print_r(pinyin("你因为穷用盗版的时候至少要知道自己是不对的,这说明你还有救。", PINYIN_UNICODE));
159117
```
160118

161119
输出结果如下,标点符号也输出了
@@ -198,10 +156,10 @@ Array
198156
#### 姓名
199157
这里使用了几个朋友的名称(比较有特色的名字)
200158
```php
201-
print_r(chinese_to_pinyin("冼佩君", PINYIN_ISNAME));
202-
print_r(chinese_to_pinyin("袁旭东", PINYIN_ISNAME));
203-
print_r(chinese_to_pinyin("燕睿涛", PINYIN_ISNAME));
204-
print_r(chinese_to_pinyin("单净净", PINYIN_ISNAME));
159+
print_r(pinyin("冼佩君", PINYIN_ISNAME));
160+
print_r(pinyin("袁旭东", PINYIN_ISNAME));
161+
print_r(pinyin("燕睿涛", PINYIN_ISNAME));
162+
print_r(pinyin("单净净", PINYIN_ISNAME));
205163
```
206164

207165
```

pinyin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ PHP_FUNCTION(pinyin)
420420
array_init(return_value);
421421
rowDataListPtr = list->next;
422422
while(rowDataListPtr != NULL) {
423-
if (l & PINYIN_UNICODE) {
423+
if (l & (PINYIN_UNICODE|PINYIN_ISNAME)) {
424424
py_add_next_index_string(return_value, rowDataListPtr->ori, 1);
425425
} else if (l & PINYIN_ASCII) {
426426
tmp[0] = 0;

0 commit comments

Comments
 (0)