Summary of the invention
The technical matters that the present invention mainly solves provides a kind of embedded device and in the method for OSD interface display spoken and written languages, can be efficiently, OSD interface convenient, that be implemented in embedded device at low cost carries out various spoken and written languages Presentation Functions.
For solving the problems of the technologies described above, the technical scheme that the present invention adopts is: a kind of method at embedded device OSD interface display spoken and written languages is provided, comprises: the character data that reads Unicode UNICODE coded format to be shown; Judge the character library at described character data place according to the UNICODE encoded radio of described character data; The UNICODE encoded radio of described character data and the UNICODE coding in the character data UNICODE coding vector table in its place character library are compared one by one, obtain the index value of described character corresponding UNICODE encoded radio in UNICODE coding vector table; Carry out address arithmetic by described index value, obtain corresponding characters dot array data offset address; Find dot array data, developed width and the altitude information of character by described offset address; Call the OSD explicit function with dot array data, width and altitude information character display according to described character.
Wherein, described UNICODE encoded radio and the step that compares one by one of the UNICODE coding in the character data UNICODE coding vector table in its place character library with character data comprises: the UNICODE encoded radio of described character data and the UNICODE coding in the character data UNICODE coding vector table in its place character library are compared one by one by dichotomy.
Wherein, described read character data step to be shown after, before whether the coding of judging described character data be Unicode UNICODE coding step, comprising: whether the pairing character string of character data of judging input is effective Unicode text formatting (UTF) character string; When pairing character string is effective UTF character string, described UTF character string is converted to the character string of UNICODE coded format; After the character string that converts the UNICODE coded format to, obtain preceding two bytes of described character string, the numerical value that merges described two bytes obtains character UNICODE encoded radio.
Wherein, described after the character string that converts the UNICODE coded format to, obtain preceding two bytes of described character string, the numerical value that merges described two bytes obtains character UNICODE encoded radio step and comprises: after converting the character string of UNICODE coded format to, character pointer is pointed to first character of described character string, wherein establish 0x0000 with pointing character string end at the end of character string; Obtain preceding two bytes of character string by described character pointer; The numerical value that merges described two bytes obtains the UNICODE encoded radio of first character; Judge whether the UNICODE encoded radio that obtains is 0x0000, judge that when being 0x0000 the current character pointer has pointed to the end of character string, enters directly whether the coding of judging described character data is Unicode UNICODE coding step.
For solving the problems of the technologies described above, another technical solution used in the present invention is: a kind of embedded device is provided, comprises: the character data reading unit is used to read the character data of Unicode UNICODE coded format to be shown; Character character library judging unit is used for judging according to the UNICODE encoded radio of described character data the character library at described character data place; The index value acquiring unit, be used for the coding of the UNICODE in the character data UNICODE coding vector table of the UNICODE encoded radio of described character data and its place character library is compared one by one, obtain the index value of described character corresponding UNICODE encoded radio in UNICODE coding vector table; The offset address acquiring unit is used for carrying out address arithmetic by described index value, obtains corresponding characters dot array data offset address; The dot array data acquiring unit is used for finding by described offset address dot array data, developed width and the altitude information of character; Character image is used to call the OSD explicit function with dot array data, width and altitude information character display according to described character.
Wherein, comprise: UTF sign indicating number judging unit, before being used for after the described character data step that reads Unicode UNICODE coded format to be shown, judging the character library step at described character data place, judge whether the pairing character string of character data of input is effective Unicode text formatting UTF character string; Transcoder unit is used for described UTF character string being converted to the character string of UNICODE coded format when pairing character string is effective Unicode text formatting UTF character string; The byte merge cells is used for after the character string that converts the UNICODE coded format to, obtains preceding two bytes of described character string, and the numerical value that merges described two bytes obtains character UNICODE encoded radio.
Wherein, comprise: multilingual string table generation unit, be used for the character string of each language is all generated independently multilingual separately string table, wherein use the coding of UTF-8 coding as each character in the character string, tables of data is made up of the UTF-8 coded data of character string vector and character string, what described character string vector was used to provide each string data deposits the relativity shift address, and described UTF-8 coded data is used to deposit the character data after each character string converts the UTF-8 coding to.
Wherein, comprising: the bitmap file generation unit is used for extracting the font of specifying size from the vector font library file that Windows operating system carries, and this font is deposited the bitmap file that obtains character with the form of bitmap; Multilingual character library generation unit, be used for described bitmap file is converted to the C language header file of character library, make the internal data structure of character in the described C language header file comprise described character data UNICODE coding vector table, character duration vector table and character pattern data vector table, and make the sequence consensus in UNICODE coding vector table, character duration vector table and the character pattern data vector table of each character in the character library.
Wherein, described embedded device is a set-top box.
The invention has the beneficial effects as follows: be different from the prior art set-top box and waste the versatility and the standardized situation of a large amount of storage spaces or sacrifice character library for realizing the OSD character display, it is fast that the present invention not only absorbs the dot matrix word library display speed that has in traditional multilingual display packing, use simple advantage, utilize the uniqueness of UNICODE coding simultaneously, promptly each character is encoded because of the double byte unsigned number of Unicode use 0 to 65535, each double byte unsigned number word table shows a unique character that uses at least in a kind of universal language, the present invention utilizes the uniqueness of above-mentioned UNICODE coding just, search the character that will show quickly and easily, do not need to waste the storage space of a large amount of programs for the embedded device character display, do not need for doing a plurality of character libraries with a kind of language, and reach the versatility and the standardization of character library, the character display efficiency is higher, need not to increase too many software design and maintenance work.
This uses the widest a kind of international character-coded mode on the internet because the present invention has used UTF again simultaneously, make embedded device such as digital TV set-top box etc. can support the demonstration of all multilingual characters in theory simultaneously, the system resource of Xiao Haoing is less simultaneously, possess speed fast, use flexibly, the code coding amount is little, code is safeguarded easily and advantage such as transplanting.
Embodiment
The words of the multilingual display technique that the family of languages of the language that the multi-lingual kind that shows based on requirement in the present top box of digital machine gets more and more, relates to is also more and more, use is traditional have a lot of problems.Can be interpreted into different symbols such as same binary digit.In computer operating system, want to open a text, just must know its coded system in advance, otherwise understand with wrong coded system, mess code will appear.Same this problem that exists in the embedded devices such as set-top box.The present invention is based on the above-mentioned issue to be resolved of wanting, use a kind of unified coded system: i.e. Unicode text formatting UTF, UTF is exactly the implementation of at present most popular on the internet a kind of unified coding, the present invention is devoted to include all language of the whole world in a unified coding, and describes in detail with the following Examples.
Consult Fig. 1, the present invention may further comprise the steps at the method embodiment of embedded device OSD interface display spoken and written languages:
Step 101: the character data that reads Unicode UNICODE coded format to be shown;
When OSD interface display spoken and written languages, the character data of the Unicode UNICODE coded format to be shown that the embedded device reading and saving is good can be a character string, also can be a character;
Step 102: the character library of judging described character data place according to the UNICODE encoded radio of described character data;
Such as there being a plurality of character libraries, corresponding not cognation, can judge the character library at described character data place according to the UNICODE encoded radio of described character data;
Step 103: the UNICODE encoded radio of described character data and the UNICODE coding in the character data UNICODE coding vector table in its place character library are compared one by one, obtain the index value of described character corresponding UNICODE encoded radio in UNICODE coding vector table;
All comprise the character data UNICODE coding vector table that points to the character address in each character library, promptly the character data UNICODE coding vector table of character address is pointed in design in advance in character library, and the character data UNICODE of institute coding vector table is as the bridge that is connected between character UNICODE coding and the character pattern data;
As the bridge that is connected between character UNICODE coding and the character pattern data, point to the character data UNICODE coding vector table of character address in the described dot array data information, be the part of the internal data structure of predefined dot matrix word library in embedded device, make and find width and the character pattern data of character in character library by character UNICODE coding easily;
Step 104: carry out address arithmetic by described index value, obtain corresponding characters dot array data offset address;
Step 105: the dot array data, developed width and the altitude information that find character by described offset address;
Step 106: call the OSD explicit function with dot array data, width and altitude information character display according to described character.
It is fast that the present invention not only absorbs the dot matrix word library display speed that has in traditional multilingual display packing, use simple advantage, utilize the uniqueness of UNICODE coding simultaneously, promptly each character is encoded because of the double byte unsigned number of Unicode use 0 to 65535, each double byte unsigned number word table shows a unique character that uses at least in a kind of universal language, the present invention utilizes the uniqueness of above-mentioned UNICODE coding just, search the character that will show quickly and easily, do not need to waste the storage space of a large amount of programs for the embedded device character display, do not need for doing a plurality of character libraries with a kind of language, and reach the versatility and the standardization of character library, the character display efficiency is higher, need not to increase too many software design and maintenance work.
In another embodiment, described UNICODE encoded radio and the step that compares one by one of the UNICODE coding in the character data UNICODE coding vector table in its place character library with character data comprises: the UNICODE encoded radio of described character data and the UNICODE coding in the character data UNICODE coding vector table in its place character library are compared one by one by dichotomy.
Character data UNICODE coding vector table, ID value, UNICODE encoded radio and dot array data information according to pointing to the character address in the dot array data information can find character data corresponding characters width and dot array data information from described character library.
In another embodiment, on the basis based on above-mentioned a plurality of character library embodiment, described UNICODE encoded radio and the step that compares one by one of the UNICODE coding in the character data UNICODE coding vector table in its place character library with character data comprises:
According to the UNICODE encoded radio of described character library ID value and character data, by binary search to the index value of corresponding character in described character library.
In another embodiment, be to realize character string display, described read character data step to be shown after, before whether the coding of judging described character data be Unicode UNICODE coding step, comprising:
1) judges whether the pairing character string of importing of character data is effective Unicode text formatting UTF character string;
Described UTF can be UTF-8, also can be UTF-16;
2) when pairing character string is effective Unicode text formatting UTF character string, described UTF character string is converted to the character string of UNICODE coded format;
3) after the character string that converts the UNICODE coded format to, obtain preceding two bytes of described character string, the numerical value that merges described two bytes obtains character UNICODE encoded radio.
Wherein, on the basis based on above-mentioned character string display embodiment, described after the character string that converts the UNICODE coded format to, obtain preceding two bytes of described character string, the numerical value that merges described two bytes obtains character UNICODE encoded radio step and comprises:
1) after the character string that converts the UNICODE coded format to, character pointer is pointed to first character of described character string, wherein establish 0x0000 with pointing character string end at the end of character string;
2) obtain preceding two bytes of character string by described character pointer;
3) numerical value of described two bytes of merging obtains the UNICODE encoded radio of first character;
4) judge whether the UNICODE encoded radio that obtains is 0x0000, judge that when being 0x0000 the current character pointer has pointed to the end of character string, enters directly whether the coding of judging described character data is Unicode UNICODE coding step.
Here, be at the end of character string 0x0000 to be set in advance, finish with expression.
Lift an Application Example below the inventive method is described, comprising:
1) tools of multilingual character library;
2) internal data format of multilingual dot matrix word library;
3) multilingual string data form;
4) Core Generator of multilingual string data;
5) a socket function of multilingual character library of GUI system call and the multilingual character string of demonstration.
Wherein:
1) tools of multilingual character library
The making of multilingual character library comprises two steps, and each step needs to use different instruments respectively, finally generates the C language header file of character library.
Step 1: use font2bitmap.exe to generate the bitmap file of character in the character library.It can be according to the font of user's setting, and character duration highly waits attribute, extracts the font of specifying size in the vector font library file that carries from Windows operating system, and this font is deposited with the form of bitmap, prepares for making character library.
Step 2: use generateFontData.exe the bitmap file of the character that step 1 generated to be converted to the C language header file of character library.
2) internal data format of multilingual dot matrix word library
The internal data structure of dot matrix word library is:
typedef?struct
{
Unsigned char Font_Height; The height of character in the // character library
Unsigned short Font_Count; The number of character in the // character library
Const unsigned char * Font_Width; Character duration vector table in the // character library
Const unsigned int * Font_Data; Character pattern data vector table in the // character library
Const unsigned short * Font_Tab; Character data UNICODE coding vector in the // character library
Table
}sky_font_t;
Say that with the data structure of existing multilingual character library character different places is, the present invention uses character data UNICODE coding vector table in this embodiment.And the order in UNICODE coding vector table, character duration vector table and the character pattern data vector table of each character is consistent in the character library, so just finds width and the character pattern data of character in character library by character UNICODE coding easily in code.
Wherein in character library, use the reason of UNICODE coding to be: because the double byte unsigned number of Unicode use 0 to 65535 is encoded to each character.Each double byte unsigned number word table shows a unique character that uses at least in a kind of universal language.The embodiment of the invention is utilized the uniqueness of UNICODE coding just, searches the character that will show quickly and easily, and conversion is very easy between UNICODE coding and the UTF-8 coding.
3) multilingual string data form
The present invention uses the coding of UTF-8 coding as each character in the character string in this embodiment, and the character string of each language all generates independently multilingual separately string table by instrument.Tables of data is made up of the UTF-8 coded data of character string vector and character string.What character string vector described here was used to provide each string data deposits the relativity shift address.Described UTF-8 coded character data are used to deposit the character data after each character string converts the UTF-8 coding to.
Below be the example and the format description of multilingual string table:
Table one: original string data example before the conversion:
Be the string data example (is example with English) after the conversion below:
const?unsigned?char?English_strs_array[]=
{
2,
0x00,0x06, // character string number
0x00,0x11, // first character string offset address
0x00,0x19, // the second character string offset address
0x00,0x1e, // the three character string offset address
0x00,0x23, // the four character string offset address
0x00,0x29, // the five character string offset address
0x00,0x34, // the six character string offset address
0x00,0x3b, the size of // character string array
The UTF-8 coded data of each character in the // character string, each character string is with the sign of 0x00 as end
0x45,0x6e,0x67,0x6x,0x69,0x73,0x68,0x00,0x4c,0x65,0x66,0x74,0x00,0x4d,0x6f,0x6e,
0x6f,0x00,0x52,0x69,0x67,0x68,0x74,0x00,0x41,0x75,0x64,0x69,0x6f,0x20,0x4d,0x6f,
0x64,0x65,0x00,0x53,0x74,0x65,0x72,0x65,0x6f,0x00,
};
Table two: string table format description:
4) Core Generator of multilingual string data
As mentioned above, be to convert the string data of each language to the UTF-8 coded format by instrument.Below be the step that generates multilingual string data by instrument:
Step 1, multilingual character string is input to an Excel file.Interpolation, modification, delete character string are all finished by revising the Excel file.In the Excel form first row are index ID tabulations of each character string, and other row are the title of each language and the character string of translation.
Table three: multilingual character string Excel table format example:
id |
German |
Indonesian |
French |
RS_LANGUAGE_CODE |
Deutsch |
Indonesian |
Francais |
RS_AC3_MODE |
AC3?Mode |
Mode?AC3 |
Mode?AC3 |
RS_APPEND |
Spurweg |
Bubuh |
Ajouter |
RS_AUDIO_MODE_left_CHANNEL |
Links |
Kiri |
Gauche |
RS_AUDIO_MODE_MONO |
Mono-Tonspur |
Mono |
Mono |
Step 2, will comprise multilingual Excel File Open and save as the text of UNICODE coded format.Character string in the text can not need to be with double quotation marks, separates and separates without the space with the tab key tab between character and the character.
Step 3, the text (as String.txt) that step 2 is generated by instrument TextEncoder.exe convert the header file and the community string index community ID file of the string data of UTF-8 coding to.The file that generates comprises str_xxx.h and string.id, here the title of xxx representation language.As the form example, we will generate str_German.h, str_Indonesian.h, str_French.h and four files of string.id.
5) the multilingual character library of GUI system call and show the interface function of multilingual character string
On realizing that multiple-language user interface shows, this method is to realize by DrawText (char*pUTF8String) function that calls among the GUI.This implementation procedure sees also process flow diagram 2:
Program is carried out beginning, at first enters step S1, and this step mainly is to judge whether the character string pUTF8String of input is effective UTF-8 character string.If be effective UTF-8 character string, then enter among the step S2, this step converts UTF-8 coded format character string to the character string of UNICODE coded format.If change successfully, then enter among the step S3, character pointer points to first character, obtains preceding two bytes of character string by character pointer, and the numerical value after two bytes merge then is the UNICODE encoded radio of first character.Enter then among the step S4, judge whether the UNICODE encoded radio obtain is 0x0000, if the result be a "Yes", then represented the current character pointed end of character string, i.e. display routine end.If the result is a "No", then carry out next procedure S5, this step is according to each character UNICODE encoded radio that will show, judge the character library at this character place, and obtain the ID value of place character library, for example, the scope of Hellenic UNICODE is from 0x0370 to 0x03FF, if the UNICODE value of the character in the display string drops on 0x0370 to 0x03FF, can judge that then this character is the Greek character, code just can go to read Hellenic character library and obtain the width and the dot array data information of Greek character like this.Next be among the step S6, this step is in conjunction with the character library ID at the multilingual character place that will show and the UNICODE encoded radio of character, by binary search to the index value of this character in the character library of place, by this index value, just can carry out address arithmetic, calculate the offset address of character pattern data.Can obtain the dot array data of character by this address again, next enter step S7, this step mainly is to call the OSD explicit function, and this character display process is come out.Final step S8, character pointer add 2 and point to the UNICODE numerical value of character late again, and return step S2, repeat each step, up to the ending of pointed character string.
Below with Greek character
The process that shows multilingual character for the example explanation.
1),
The UNICODE of character is encoded to 0x03ab.Just drop between the UNICODE scope 0x0370-0x03FF of Greece character,, can judge that this character is the Greece character character.
2), the UNICODE encoded radio by character, use binary search
The index value of character in the Greek character library.Below be the code of the algorithm searched, wherein parameters u AimCode is 0x03ab in this example for searching the UNICODE encoded radio of character.The pTabUnicode pointed be character data UNICODE coding vector table in the character library, sequence consensus in the order of character and the character pattern tables of data in this coding schedule.
BOOL?Font_Search(unsigned?short?uStart,unsigned?short?uEnd,
unsigned?short?uAimCode,unsigned?short*pTabUnicode,unsigned?short
*uIdx)
{
unsigned?short start,end,len;
unsigned?short midValue;
for(start=uStart,end=uEnd;start<=end;)
{
midValue=pTabUnicode[(start+end+1)/2];
if((start==end)&&(uAimCode!=midValue))
{
*uIdx=0;
return?FALSE;
}
if(uAimCode>midValue)
{
start=(end+start+1)/2;
}
else?if(uAimCode<midValue)
{
end=(end+start)/2;
}
else
{
* uIdx=(start+end+1)/2; Index value is returned in // success
return?TRUE;
}
}
*uIdx=0;
return?FALSE;
}
3), by index value, obtain the offset address of character in an entire data, thereby calculate dot array data.
4), the explicit function by bottom OSD shows the dot array data that obtains on terminal, because the OSD display interface is mainly realized the demonstration of character by the picture point function at present, for display efficiency and the speed of accelerating character, this function mainly realizes by hardware-accelerated, after the character pattern data are write the OSD buffer memory, just reporting system CPU copies dot array data in the video encoder to by hardware, and character is shown.
Consult Fig. 3,, also provide a kind of embedded device embodiment, comprising based on spirit of the present invention:
The character data reading unit is used to read the character data of Unicode UNICODE coded format to be shown;
Character character library judging unit is used for judging according to the UNICODE encoded radio of described character data the character library at described character data place;
The index value acquiring unit, be used for the coding of the UNICODE in the character data UNICODE coding vector table of the UNICODE encoded radio of described character data and its place character library is compared one by one, obtain the index value of described character corresponding UNICODE encoded radio in UNICODE coding vector table;
The offset address acquiring unit is used for carrying out address arithmetic by described index value, obtains corresponding characters dot array data offset address;
The dot array data acquiring unit is used for finding by described offset address dot array data, developed width and the altitude information of character;
Character image is used to call the OSD explicit function with dot array data, width and altitude information character display according to described character.
The foregoing description is a uniqueness of utilizing the UNICODE coding, search the character that will show quickly and easily, do not need to waste the storage space of a large amount of programs for the embedded device character display, do not need for doing a plurality of character libraries with a kind of language, and reach the versatility and the standardization of character library, the character display efficiency is higher, need not to increase too many software design and maintenance work.
Consult Fig. 4, in a further embodiment, for realizing character string display, described embedded device also comprises:
UTF sign indicating number judging unit, before being used for after the described character data step that reads Unicode UNICODE coded format to be shown, judging the character library step at described character data place, judge whether the pairing character string of character data of input is effective Unicode text formatting UTF character string;
Transcoder unit is used for described UTF character string being converted to the character string of UNICODE coded format when pairing character string is effective Unicode text formatting UTF character string;
The byte merge cells is used for after the character string that converts the UNICODE coded format to, obtains preceding two bytes of described character string, and the numerical value that merges described two bytes obtains character UNICODE encoded radio.
In a further embodiment, for realizing the making of character string, described embedded device comprises:
Multilingual string table generation unit, be used for the character string of each language is all generated independently multilingual separately string table, wherein use the coding of UTF-8 coding as each character in the character string, tables of data is made up of the UTF-8 coded data of character string vector and character string, what described character string vector was used to provide each string data deposits the relativity shift address, and described UTF-8 coded data is used to deposit the character data after each character string converts the UTF-8 coding to.
In a further embodiment, for making multilingual character library, described embedded device comprises:
The bitmap file generation unit is used for extracting the font of specifying size from the vector font library file that Windows operating system carries, and this font is deposited the bitmap file that obtains character with the form of bitmap;
Multilingual character library generation unit, be used for described bitmap file is converted to the C language header file of character library, make the internal data structure of character in the described C language header file comprise described character data UNICODE coding vector table, character duration vector table and character pattern data vector table, and make the sequence consensus in UNICODE coding vector table, character duration vector table and the character pattern data vector table of each character in the character library.
Described embedded device of the present invention can be a set-top box, also can be other various embedded devices that need character display information.
The above only is embodiments of the invention; be not so limit claim of the present invention; every equivalent structure or equivalent flow process conversion that utilizes instructions of the present invention and accompanying drawing content to be done; or directly or indirectly be used in other relevant technical fields, all in like manner be included in the scope of patent protection of the present invention.