. NET to JAVA pinyin component,. netjava pinyin
PS: after four years, I feel like myself. NET to the bottleneck, and the company has not used it in depth. NET technology projects, self-learning does not feel much motivation (Please scold me for being lazy T_T ). In addition, the higher the technical life, the more I learned. the environment for NET career improvement is getting harder and harder (in my personal understanding, I don't need to spray it, and it doesn't affect me either, hahaha ). So I started learning JAVA technology half a month ago. The company just set up a JAVA Development Team and applied for the transfer. Many components of the company are in the. NET environment. For pure JAVA siege lions, it is also a headache for. NET code. Therefore, such tasks are thrown to me.
Due to the company's business needs, uncommon words in Chinese names (for commonly used GB2312, not GBK) need to be identified and converted into pinyin. For multiple Chinese names, duplicate names appear in the entire pinyin string. You need to prompt. First, let's talk about the algorithm: GB2312 has its own encoding table and Pinyin index table (I found it online here). Then, you can create a resource Array Based on the search algorithm you designed. 16 ~ of GB2312 ~ The level-1 Chinese Characters in Area 55 are sorted by pinyin. Convert the first-level Chinese character to a byte array and locate the resource array based on the algorithm to find the corresponding pinyin. 56 ~ of GB2312 ~ Because secondary Chinese Characters in Area 87 do not use Pinyin sorting, they can be specially processed or compatible algorithms can be designed (so resource arrays need to be designed by themselves ). For uncommon words: uncommon words that exceed the Chinese character location in GB2312 (of course, the byte array is still two digits). Currently, we use direct import of uncommon word information in GBK to create an index and then perform index matching.
Conversion from a Chinese character string to a byte array: In. NET, the Chinese character string uses GB2312 and GBK encoding methods. For uncommon characters, the obtained bytes are two-byte arrays in GBK. But in JAVA, what we get with GB2312 is a "?" Only GBK can be used to obtain the corresponding two-byte array. (After all, GBK is completely backward compatible with GB2312) unsigned integer: Because the index resource is used, the unsigned integer is used for related index calculation.. NET has its own unsigned integers, but JAVA does not have any signed integers. Therefore, you need to perform the ascending operation and storage (UInt16 corresponds to Int and UInt32 corresponds to Long ). Byte array (two bytes) to unsigned integer:. NET has a direct method. Note that when some methods are rotated, the low position is at the front, while the high position is at the back. JAVA needs to write the corresponding method. Note the conversion of high and low bits and the representation of Uint in JAVA. File Reading: Because you need to read uncommon words, the file format is converted to UTF-8. In Windows, MS adds a BOM (Byte Order Mark) to the header of a non-ASCII file, marking in bytes. When JAVA reads a file containing BOM, a question mark (?) appears when it reads the first character ?, May affect the subsequent processing of the program. The solution is also relatively simple. You can use a software similar to NOTEPAD ++ to convert it into a code without BOM.
The syntax is basically the same, but JAVA does not have so many built-in syntaxes. Many underlying layers need to be compiled by themselves (the company does not allow reference to third-party class libraries ). It seems that. NET is very convenient, but if you don't take the initiative, you don't need to understand a lot of things at the bottom of the computer. (In fact, I am still lazy T_T) JAVA requires a lot of knowledge at the underlying layer to implement correct programming. Although it is painful, I personally feel that there will be a lot of things to understand. I feel that. NET is indeed a very good language, but if there is no initiative, JAVA is very helpful for programmers to understand Program-related knowledge.