// -------------------------------------------------------------- Obtain the 8-character Chinese Character pinyin ------------------------------------------------ Tbuf <128> ainfo1 (L "kerrnone "); Tbuf <128> ainfo2 (L "kerrnotsupported "); _ Lit8 (kstrtest, "Zhengzhou "); Hbufc * Ptest = nhelper: convgbk2unil (kstrtest); // This function is defined in other files. The function is to convert the kstrtest short character to a GBK character. Cptiengine * aengine = cptiengine: newl (); Aengine-> activatelanguagel (elangprcchinese ); Const tuint16 * nuint = Ptest-> des (). PTR (); Tbuf <128> aout; Tint nret = aengine-> getspelling (* nuint, aout, eptipinyin ); If (nret = kerrnone) { Ceikonenv: static ()-> infowinl (ainfo1, aout ); } Else if (nret = kerrnotsupported) { Ceikonenv: static ()-> infowinl (ainfo2, ainfo2 ); } Else { Ceikonenv: static ()-> infowinl (aout, aout ); } If (Ptest) { Delete Ptest; Ptest = NULL; } Aengine-> closecuritydomainagel (); If (aengine) { Delete aengine; Aengine = NULL; } // -------------------------------------------------------- Obtain the first letter of the Chinese alphabet with a length of 16 characters ------------------------------------------------------ Cptiengine * aengine = cptiengine: newl (); Aengine-> activatelanguagel (elangprcchinese ); // Total number of records Tint ncount = iallrecord. Count (); For (tint I = 0; I <ncount; I ++) { // How long is the name of each record? Tint nnamelength = iallrecord [I]-> INAME. Length (); For (tint J = 0; j <nnamelength; j ++) { Tuint16 iint16 = iallrecord [I]-> INAME [J]; Tbuf <3> bmid; Bmid. append (iallrecord [I]-> INAME. mid (J, 1 )); // If the character is a Chinese character If (iint16> = 0x4e00) & (iint16 <= 0x9fa5 )) { Hbufc * Ptest = hbufc: newl (6 ); Ptest-> des (). append (bmid ); Const tuint16 * nuint = Ptest-> des (). PTR (); Tbuf <128> aout; Tint nret = aengine-> getspelling (* nuint, aout, eptipinyin ); If (nret = kerrnone) { // If you have obtained a full spell, only the first spell is captured. If (0 <aout. Length ()) { Iallrecord [I]-> ijianpin. append (aout. mid (0, 1 )); } } Mem_free (Ptest ); } // If it is not a Chinese character, append the letter to the shortlist. Else { Iallrecord [I]-> ijianpin. append (bmid ); } } } Aengine-> closecuritydomainagel (); Mem_free (aengine ); |