Content of the invention
In view of this, present invention aim at providing a kind of embedded electronic product character library, character library generation method and character library
Lookup method, to realize quickly generating the character library comprising required arbitrary number type matrix, the management of convenient difference character library, and be easy to
Type matrix needed for quick lookup simultaneously shows corresponding word.
For solving above technical problem, the technical scheme that the present invention provides is:A kind of character library of embedded electronic product, be
All input files meeting form are carried out with dissection process and obtains Unicode coding, realize deduplication coding simultaneously and sort
After process, freely form the set of required coding type matrix.
More preferably, it is provided with character library index structure body in described character library, for recording one section of continuous arrangement type matrix in character library
The correspondence position call number information of the start code of start code, the coding number of this coding section and this coding section of coding.
The present invention provides a kind of character library generation method of embedded electronic product, comprises the following steps:
All input files meeting form are parsed, obtains Unicode coded data;
Abandon the repeated encoding in Unicode coded data;
Unicode coded data after deduplication coding is ranked up, freely forms the set of required type matrix.
More preferably, for each input file, comprise the following steps:
A storage class example is created before parsing;
This input file is parsed, the Unicode coding that each is parsed is delivered in this storage class example and carried out
Distinguish process, after abandoning the coding repeating, the order of arranging and encoding;
After completing the parsing of whole file, modification storage class list items are this import file name, and are saved in a management class
In the list of example.
More preferably, all stored the content of class example by management class instance enumeration traversal, merge and generate a new storage class
Example;And this new storage class example deduplication coding and sequence are processed, using this new storage class example traversal coding life
Become corresponding character library.
More preferably, type matrix is obtained by type matrix coded sequence, preserved to character library with structure of arrays form.
More preferably, type matrix is obtained by type matrix coded sequence, preserved to character library with bin file form.
More preferably, include index structure body in this bin file, for recording one section of continuous arrangement type matrix in current character library
The correspondence position call number information of the start code of start code, the coding number of this coding section and this coding section of coding.
On this basis, the present invention also provides a kind of character library lookup method of embedded electronic product, and this character library is to institute
There is the input file meeting form to carry out dissection process and obtain Unicode coding, realize deduplication coding simultaneously and sequence is processed
Afterwards, freely form the set of required coding type matrix, including:
With code page conversion table, local code is converted into Unicode coding;
Using two way classification, the index structure body list in this character library is made a look up, this index structure body is used for recording currently
The start code of start code, the coding number of this coding section and this coding section of one section of continuous arrangement type matrix coding in character library
Correspondence position call number information.
More preferably, this index structure body preserves tactic continuous programming code section, and wherein, binary search includes following step
Suddenly:
First, using this coding section original position of binary search;
Then, judge whether the Unicod coding searched belongs within this coding section, such as no, carry out next binary chop;
In this way, directly calculate the Unicode coding searched and the position deviation value of the start code of this coding section, therefrom calculate correspondence
The positional information of coding type matrix;
Finally, directly read the character pattern data in this character library according to this position deviant, and show corresponding word
Compared with prior art, the obtainable Advantageous Effects of the present invention are:When character library changes in demand, can fast fast-growing
Become required type matrix delete character library;And for different compiling form files, can meet corresponding selection requires, thus can
To quickly generate corresponding character library;And adopt index structure body information to preserve, the lookup speed reading type matrix can be lifted, improve
Such that it is able to put forward the performance doing electronic product.
Specific embodiment
The key point of the present invention and protection point are:Dissection process is carried out to obtain to the multiple difference files meeting form
Unicode encodes, and realizes removing repeated encoding simultaneously and sequence is processed, the character library required for freely forming.Especially, add
Character library index structure body information, for recording the start code information of continuous arrangement coding in character library, when reading formed word module information
Wait and using two way classification, index structure body list is made a look up, can quickly find the position of required type matrix.
In order that those skilled in the art more fully understands technical scheme, below in conjunction with the accompanying drawings and specifically real
The present invention is described in further detail to apply example.
The character library of the embedded electronic product of the present invention is to carry out dissection process to the various input files meeting form to obtain
Unicode is taken to encode, after realizing deduplication coding and sequence process, the set freely forming required coding type matrix is institute simultaneously
The character library needing.
Preferably, it is preferably provided with character library index structure body in this character library, for recording one section of continuous arrangement in character library
The correspondence position call number letter of the start code of start code, the coding number of this coding section and this coding section of type matrix coding
Breath.
Referring to Fig. 1, the file structure of an embodiment of embedded electronic product character library of the present invention, wherein bag character library header
Area, index information area and formed word module information area, index 1~n and type matrix 0x0012~n corresponds, and is so reading formed word module information
When using two way classification, index structure body list can be made a look up, can quickly find the position of required type matrix.
Character library for embedded electronic product of the present invention, it is possible to provide three kinds of compiling form input files:
A, comprise Unicode coding file:Write out needing the Unicode coding corresponding to the word type matrix preserving
Come, form is started with hexadecimal mark " 0x " or " 0X ", be to terminate with English symbol ", " or space, alphabet size is write and do not limited.
Maskable " // " parsing part between Analytic Traveling after symbol or "/* " and " */".
B, local code change the file of Unicode coding:Compiled according to multi-lingual local code and corresponding Unicode
Code, corresponding two codings is write in a row, form is consistent with hexadecimal format, before for local code, after be
Unicode code, centre space separates.Analytic Traveling part after maskable " # " symbol.
C, with Unicode coded format preserve needed for word file:The passage that need are preserved type matrix is stored in literary composition
In presents, change this file coding format into Unicode type.
According to needing can select different compiling form files in device product using the different situations of word, character library is given birth to
One-tenth instrument needs document analysis to be become corresponding Unicode coded data save.
Referring to Fig. 2, it is the flow chart of character library generation method one embodiment of embedded electronic product of the present invention, main inclusion
Following steps:
S201, all input files meeting form are parsed, obtain Unicode coded data.These input literary compositions
Part can may also be employed meeting other forms of character library requirement as above-mentioned file format a, b, c.
S202, the repeated encoding abandoned in Unicode coded data.As for the Latin alphabet, for numeral waits, in difference
All may there is coding, so that rejecting to these duplicated codes occurring in language.
S203, to deduplication coding after Unicode coded data be ranked up, freely form the collection of required type matrix
Close.After rejecting redundancy encoding, then these coded data are ranked up, adopt the search methods such as two way classification after can facilitating to word
Mould makes a look up.
Generating the input file that may use during character library, following processing methods can adopted:
The file inputting for each, will create a storage class example, the Unicode that each is parsed before parsing
Coding is delivered in storage class example and is carried out distinguishing process, abandons the coding repeating, simultaneously the order of arranging and encoding, completes whole
After the parsing of individual file, modification storage class list items this filename entitled, and be saved in management class example list in.
When needing to add alternative document, other storage class example, now all storages will be generated by above procedure
Deposit class example by the list being saved in management class example, show as listed files.
When generating specific character library, then the content all storing class is traveled through by management class instance enumeration, merge and generate newly
Storage class example, it will comprise whole Unicode codings, and ensure that order arranges and encodes and do not repeat.Finally by volume
Code order obtain type matrix, with structure of arrays or bin file (binary file, purposes is depending on system or application) form preserve to
In character library.
Wherein, if preserved using bin file form, font file structure can be as shown in Figure 1.Contain in this document
Index structure body information, encodes for recording the start code of one section of continuously arranged type matrix coding, this section in current character library
Coding number and the location index number corresponding to start code type matrix of this section of coding, can pass through two way classification and index structure afterwards
Body quickly finds the position of required type matrix.
Referring to Fig. 3, the flow process of character library lookup method one embodiment of embedded electronic product of the present invention is shown, concrete bag
Include:
As step S301, when searching and show word, first with code page conversion table, local code is converted into Unicode
Coding.
As step S302, then using two way classification, the index structure body list in character library is made a look up, wherein, this index
Structure is used for recording in current character library the start code of one section of continuous arrangement type matrix coding, the coding number of this coding section and should
The correspondence position call number information of the start code of coding section.
Referring to Fig. 4, the detailed process of binary search is shown:
As step S401, first by certain coding section original position of binary search.
As step S402, then judge whether to belong within coding section, if it is not, then return to step S401, that is, carry out
Next binary chop;If it is, entering step S403.
As step S403, directly calculate the deviation value of the Unicode coding searched and this section of coding original position, from falling into a trap
Calculate the positional information of corresponding coding type matrix;
As step S403, offset, finally according to position, the character pattern data directly reading in character library and be used for showing word.
Above-described embodiment adopts input file up to specification, and all input file lists are parsed and obtained correspondence
Unicode coding, then carry out de-redundancy and sequence and process, thus realizing quickly generating comprising required arbitrary number type matrix
Character library, is also convenient for the management of different character libraries.
Additionally, searching speed to improve the type matrix deleting rear character library, the interior coded sequence of pressing of character library preserves formed word module information, with
When provide code index structure list.The lookup method ratio of index structure body thus can be adopted directly to coding lookup, thus
The positional information of required type matrix can faster be found.
The present invention can be in multiple embedded electronic products, below for a specific application example, for example:Certain product at present
Product only need to preserve several sections of words for operation show, but requirement can change using one or several country variant words
Version of display.
For this reason, translating to the content of this several sections of words first, the different editions of the national word required for obtaining.Will
Different editions are saved in each file, and its coded format is revised as Unicod form, now meet Unicode format
Country variant character input file is carried out.
Need further according to specific, select different input files to carry out dissection process.Now dissection process needs to arrange
It is to read by byte format, reads two bytes every time as Unicode encoded radio, deliver in storage class example and carry out at judgement
Reason, by abandon the coding repeating and simultaneously arranging and encoding sequentially, finally this national character file name is saved as storage class
List items title, preserve storage class to management class example list in.
When needing to add other countries' character, its storage class example will be obtained by adding respective country character file,
After last whole countries character file required for determination has comprised, each is traveled through by management class instance enumeration and stores class example
The Unicode coding comprising, merge the new storage class example of generation guarantees its order arrangement and non-duplicate coding simultaneously, thus profit
Generate corresponding character library with this new storage class example traversal coding.
So, the required type matrix that can quickly generate when character library changes in demand delete character library;And different are write
Formatted file, can meet corresponding selection and require, such that it is able to quickly generate corresponding character library.
As it was previously stated, this character library includes index structure body information, can be rapidly performed by searching and display, for example:
Contain 8200 formed word module information in character library, be presented herein below and directly coding carried out with binary search and utilizes index structure body information
Carry out binary search to be compared:
Directly binary search is carried out to coding, then complete for the fastest 1 time, want the most slowly 12 times.
Carry out binary search using index structure body information, two kinds can be divided to analyze the continuous situation of coding.If
Type matrix coding is all linked in sequence, then only one of which index structure body, as long as just can complete at most 1 time to search;If
Type matrix coding is entirely detached, then index structure body has 8200, completes for the fastest 1 time, is also to complete for 12 times the most slowly.
But in most of character library uses, majority occurs the situations of coding continuous segment, and at this moment index structure body is
Slow situation will complete less than 12 times, so can than directly to coding lookup more faster using index structure body information searching.
As can be seen here, after using the preservation of index structure body information, the lookup speed reading type matrix can be lifted, final raising
The performance of electronic product.
The above is only the preferred embodiment of the present invention it is noted that above-mentioned preferred implementation be not construed as right
The restriction of the present invention, protection scope of the present invention should be defined by claim limited range.For the art
For those of ordinary skill, without departing from the spirit and scope of the present invention, some improvements and modifications can also be made, these change
Enter and retouch also to should be regarded as protection scope of the present invention.