- function ChineseCharToPinyin(w: WideString): string;
- var
- vGuid: TGUID;
- vFELanguage: IFELanguage;
- vError: Integer;
- vCaps: DWORD;
- vOutput: PMORRSLT;
- vPinYin: WideString;
- S: WideString;
- I: Integer;
- iMonoRubyPos: WORD;
- iReadIdxWDD: WORD;
- vMonoRubyPos: PWORD;
- vReadIdxWDD: PWORD;
- begin
- Result := EmptyStr;
- if CLSIDFromString(PWideChar(WideString('MSIME.China')), vGuid) <> S_OK then
- Exit;
- vError := CoCreateInstance(vGuid, nil, CLSCTX_SERVER,
- IFELanguage, vFELanguage);
- if vError <> S_OK then
- Exit;
- vError := vFELanguage.Open;
- if vError <> S_OK then
- Exit;
- vCaps := 0;
- vError := vFELanguage.GetConversionModeCaps(@vCaps);
- if vError <> S_OK then
- Exit;
- vOutput := nil;
- vError := vFELanguage.GetJMorphResult(FELANG_REQ_REV,
- FELANG_CMODE_PINYIN or FELANG_CMODE_NOINVISIBLECHAR,
- Length(W), PWideChar(W), nil, @vOutput);
- if vError <> S_OK then
- Exit;
- if not Assigned(vOutput) then Exit;
- vPinYin := Copy(vOutput^.pwchOutput, 1, vOutput^.cchOutput);
- Result := vPinYin;
- CoTaskMemFree(vOutput);
- vFELanguage.Close;
- vFELanguage := nil;
- end;
把汉字转换为拼音
最新推荐文章于 2024-09-14 11:42:29 发布