Drawing method and device, electronic equipment and readable storage medium

By parsing and merging character encoding units in Linux system, the problem of abnormal text display of old printers under Linux system is solved, and compatibility and usability are improved.

CN120509382APending Publication Date: 2025-08-19ZHONGKE FANGDE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510533004.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

Old printers lack native drivers under Linux systems, resulting in abnormal text display, data loss or errors, hindering the development of Linux desktops.

Method used

Provides a drawing method to ensure that characters are displayed correctly under Linux systems by receiving task requests, parsing encoding units of characters, merging or converting encoding units to generate appropriate drawing instructions.

Benefits of technology

It reduces the possibility that garbled characters and special characters are lost or replaced with placeholders in Linux systems, and improves the compatibility and usability of Linux systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120509382A_ABST
    Figure CN120509382A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a drawing method and device, electronic equipment and a readable storage medium. The method comprises the steps that a task request sent by a target application program is received; analyzing a character string from the task request, and reading a first coding unit of each character in sequence; under the condition that the first coding unit of the character falls into the first preset coding interval, combining the first coding unit with the next coding unit of the first coding unit, and determining a font corresponding to the character; under the condition that the first coding unit of the character does not fall into the first preset coding interval, determining a font corresponding to the character according to the first coding unit; and according to the font corresponding to each character, a drawing instruction corresponding to the character string is generated, and the drawing instruction is sent to the external equipment, so that the possibility that messy codes appear when the embedded equipment displays and prints the character string and special characters in the character string are possibly lost or replaced by placeholders is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a drawing method, device, electronic device, and readable storage medium. Background Art

[0002] Currently, Linux has a limited market penetration and relatively low usage. Furthermore, there is a lack of application software developed for Linux, and few hardware manufacturers have developed native drivers for Linux. For example, a large number of older printers lack native Linux drivers. After governments and businesses migrated from Windows to Linux, a large number of these printers became unusable. This not only wastes resources but also severely hinders the Linux replacement process, further hindering the development of the Linux desktop and creating a vicious cycle.

[0003] Prior art uses a compatibility layer deployed on a Linux operating system to allow Windows applications to run on Unix-like operating systems. However, the compatibility layer can only process text content in a specific encoding format, which can lead to text display anomalies, data loss, or errors. Summary of the Invention

[0004] The embodiments of the present application provide a drawing method, device, electronic device, and readable storage medium, which can solve the problems of abnormal text display, data loss, or errors.

[0005] In a first aspect, an embodiment of the present application discloses a drawing method, the method comprising:

[0006] receiving a task request sent by a target application; the task request is used to instruct the embedded device to use at least one external device to perform a corresponding task;

[0007] Parsing a character string from the task request and reading the first encoding unit of each character in sequence;

[0008] When the first encoding unit of the character falls within a first preset encoding interval, merging the first encoding unit and the next encoding unit of the first encoding unit, and determining a glyph corresponding to the character;

[0009] If the first encoding unit of the character does not fall within the first preset encoding interval, determining the glyph corresponding to the character according to the first encoding unit;

[0010] A drawing instruction corresponding to the character string is generated according to the glyphs corresponding to the respective characters, and the drawing instruction is sent to the external device; the drawing instruction is used to control the external device to draw the glyphs of the respective characters in the character string.

[0011] Optionally, when the first encoding unit of the character falls within a first preset encoding interval, merging the first encoding unit with a next encoding unit of the first encoding unit, and determining a glyph corresponding to the character, includes:

[0012] When the first encoding unit of the character falls within a first preset encoding interval, determining a proxy area corresponding to the character according to a conversion rule between a first encoding format corresponding to the first encoding unit and a second encoding format supported by the external device;

[0013] Merging the first encoding unit and the next encoding unit of the first encoding unit according to the proxy area to determine a target encoding value corresponding to the character;

[0014] The glyph corresponding to the character is determined according to the target code value.

[0015] Optionally, the proxy area includes the first preset coding interval and the second preset coding interval; and merging the first coding unit and the next coding unit of the first coding unit according to the proxy area to determine the target coding value corresponding to the character includes:

[0016] Performing a subtraction operation on the first encoding unit of the character and the minimum value of the first preset encoding interval to obtain a first operation result;

[0017] performing a subtraction operation on the next coding unit of the first coding unit and the minimum value of the second preset coding interval to obtain a second operation result; the maximum value of the first preset coding interval is less than the minimum value of the second preset coding interval;

[0018] Shift the first operation result left by 10 bits to obtain a third operation result;

[0019] Determine the target encoding value corresponding to the character based on the second operation result and the third operation result.

[0020] Optionally, parsing the character string from the task request and sequentially reading the first encoding unit of each character includes:

[0021] Set an offset and initialize the offset to 0;

[0022] When the offset is less than the length of the character string, reading a character and a first encoding unit corresponding to the character from the character string according to the offset;

[0023] Each time a character and the first encoding unit corresponding to the character are read, the offset is increased by one until the offset is greater than or equal to the length of the character string, and the traversal of the character string is stopped.

[0024] Optionally, the method further includes:

[0025] Determining the encoding format of the character according to the function name called in the task request;

[0026] Determining a first encoding unit of the character according to the encoding format of the character;

[0027] According to a comparison result between the first encoding unit of the character and the first preset encoding interval, it is determined whether the first encoding unit of the character falls within the first preset encoding interval.

[0028] In a second aspect, an embodiment of the present application discloses a drawing device, comprising:

[0029] A receiving module, configured to receive a task request sent by a target application; the task request is used to instruct the embedded device to perform a corresponding task using at least one external device;

[0030] A parsing module, configured to parse a character string from the task request and sequentially read the first encoding unit of each character;

[0031] A first determining module is configured to merge the first encoding unit and the next encoding unit of the first encoding unit when the first encoding unit of the character falls within a first preset encoding interval, and determine a glyph corresponding to the character;

[0032] a second determining module, configured to determine a glyph corresponding to the character according to the first encoding unit if the first encoding unit of the character does not fall within a first preset encoding interval;

[0033] The generating module is used to generate a drawing instruction corresponding to the character string according to the glyphs corresponding to the characters, and send the drawing instruction to the external device; the drawing instruction is used to control the external device to draw the glyphs of the characters in the character string.

[0034] In a third aspect, an embodiment of the present application discloses an electronic device, which includes a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the aforementioned drawing method.

[0035] In a fourth aspect, an embodiment of the present application discloses a readable storage medium, which, when instructions in the readable storage medium are executed by a processor of an electronic device, enables the electronic device to execute the aforementioned drawing method.

[0036] The embodiments of the present application include the following advantages:

[0037] The drawing method provided in the embodiment of the present application can receive a task request sent by a target application; parse a character string from the task request and read the first encoding unit of each character in sequence; if the first encoding unit of a character falls within a first preset encoding interval, merge the first encoding unit and the next encoding unit of the first encoding unit and determine the glyph corresponding to the character; if the first encoding unit of a character does not fall within the first preset encoding interval, determine the glyph corresponding to the character based on the first encoding unit; generate a drawing instruction corresponding to the character string based on the glyph corresponding to each character, and send the drawing instruction to an external device. In the embodiment of the present application, by determining the encoding format of the character based on the interval in which the first encoding unit of the character is located; by converting the encoding format not supported by the embedded device, the possibility of garbled characters appearing when the embedded device displays, prints, or draws the character string, and the possibility of special characters in the character string being lost or replaced with placeholders can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0039] Figure 1 is a flowchart of steps of an embodiment of a drawing method of the present invention;

[0040] Figure 2 It is a structural block diagram of a drawing device of the present invention;

[0041] Figure 3 This is a structural block diagram of an electronic device provided by an example of the present invention. DETAILED DESCRIPTION

[0042] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0043] The terms "first", "second", etc. in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after the association are in an "or" relationship. In the embodiments of the present invention, the term "multiple" refers to two or more, and other quantifiers are similar.

[0044] Method Example

[0045] Reference Figure 1 , shows a flowchart of a drawing method embodiment of the present invention, the method may specifically include the following steps:

[0046] Step 101: Receive a task request sent by a target application; the task request is used to instruct the embedded device to use at least one external device to perform a corresponding task;

[0047] Step 102: Parse the character string from the task request and read the encoding unit of each character in sequence;

[0048] Step 103: When the first encoding unit of the character falls within a first preset encoding interval, merge the first encoding unit and the next encoding unit of the first encoding unit, and determine the glyph corresponding to the character;

[0049] Step 104: if the first encoding unit of the character does not fall within the first preset encoding interval, determine the glyph corresponding to the character according to the first encoding unit;

[0050] Step 105 : Generate a drawing instruction corresponding to the character string according to the glyphs corresponding to the respective characters, and send the drawing instruction to the external device; the drawing instruction is used to control the external device to depict the glyphs of the respective characters in the character string.

[0051] The drawing method provided in the embodiment of the present application can be applied to embedded devices with Unix-like operating systems, such as Linux operating systems and Mac operating systems. Among them, the external device can be a printer, a display, and other devices. It should be noted that a compatibility layer, Wine, is deployed on the embedded device. Wine is an open source compatibility layer that allows Windows programs to run on Unix-like operating systems. Specifically, the Windows program sends a task request, the compatibility layer intercepts the task request, and converts the task request into an instruction format supported by the external device. For example, the external device is a printer, and the task request is DrawText(hdc,"Hello, Windows!"). After Wine processes the task request, it generates a PostScript instruction "(Hello, Windows!) show" that the printer can recognize. The Windows program is the target application. The target application refers to a program originally designed for the Windows system. The task request can be a print request, a display request, a storage request, etc. The target application sends the task request through the graphics device interface, and Wine receives the task request through its own graphics subsystem. After processing the task request, the service module in the embedded device sends the processed task request to the external device.

[0052] For example, when the task request is a print request, the external device is a printer, and the request is used to instruct the embedded device to use at least one printer to print the print content contained in the print request. Specifically, wine sends the print request to the print driver through its own graphics subsystem. The print driver converts the print request into an encoding format that the printer can support and recognize, and generates the final print instruction. The final print instruction is sent to the printer through the print service module in the embedded device, and the printer prints the content to be printed in the print request according to the print instruction. The print request may include information such as text content, font information, and print location.

[0053] Among them, the character string refers to the text content that needs to be printed carried in the print request. The print request can also carry other forms of print content, such as graphics and lines. Among them, graphics and lines are defined by numerical data such as coordinates, colors, styles, etc., and it is only necessary to identify the encoding format of the text content and perform corresponding processing. Specifically, the text content exists in the form of a character string, such as "This is a printing test question, A, B, C, D", and the character string is parsed from the task request, and each character is read from the character string in turn, and the first encoding unit corresponding to each character is determined, and it is judged whether the first encoding unit corresponding to the character is in the first preset encoding range. Among them, the wine in the embodiment of the present application processes characters in the UTF-16 encoding format by default, and there is a one-to-one correspondence between characters and UTF-16 encoding. In the case where the character is not in the UTF-16 encoding format, the encoding value corresponding to the character is not an independent UTF-16 encoding unit, and it is impossible to determine the character based on a 16-bit encoding unit corresponding to the character, and then print the character correctly.

[0054] It should be noted that the coding unit refers to the smallest unit used to identify a single character under a certain coding format, and the coding unit corresponds to the coding format. Specifically, in UTF-8 encoding, the coding unit can be 1 to 4 bytes; for ASCII characters, when the UTF-8 encoding format is used, 1 byte is used as the coding unit; for Unicode characters, 2, 3, or 4 bytes may be required. If the character adopts the UTF-16 encoding format, the coding unit is 2 bytes; special characters require two coding units to be identified, and special characters refer to characters located in the Unicode supplementary plane. Since the compatibility layer processes 16-bit or 2-byte coding units by default, for characters represented by two coding units, each coding unit will also be processed separately, which will cause garbled characters in the final printed content. The first coding unit refers to the coding unit that is first read when reading the coding value corresponding to the character. In an embodiment of the present application, the number of coding units actually corresponding to the character will be determined based on the size relationship between the first coding unit and the first preset coding interval. When the first encoding unit falls within the first preset encoding interval, it indicates that the character actually corresponds to two encoding units; when the first encoding unit does not fall within the first preset encoding interval, it indicates that the character actually corresponds to one encoding unit.

[0055] It should be noted that in this application, the compatibility layer defaults to supporting and processing code units that are equal to or fewer than the code units required to represent a character. For example, the compatibility layer defaults to supporting 16-bit code units, while the code units required to represent a character can be 16-bit or 32-bit. If the code unit required to represent a character is larger than the code unit supported by the compatibility layer, the code unit corresponding to the character and the next code unit need to be merged and processed as a whole. Otherwise, if, for example, a character requires two code units to represent, the compatibility layer will process the two code units representing the same character separately, and a single code unit cannot represent the complete information of the character, resulting in garbled characters. If the code unit required to represent a character is consistent with the code unit supported by the compatibility layer device, the code unit corresponding to the character does not need to be processed separately. In addition, after the compatibility layer determines and processes the code unit for each character, it also converts the encoding format corresponding to each character into the encoding format supported by the embedded device. For example, if an embedded device running the Linux operating system supports the UTF-8 encoding format, the encoding format corresponding to each character will be further converted to the UTF-8 encoding format.

[0056] In an embodiment of the present invention, a task request may include font information for indicating the style of the text content to be printed, stored, or displayed. The embedded device parses the font information from the task request, first determines the target font indicated by the task request, and then determines the glyph of the character in the target font based on the encoding unit corresponding to the character. Specifically, when a Windows program sends a task request, the request usually specifies the font to be used, and the font information includes the font name, style (such as regular, bold, italic, etc.) and size. A font that matches the task request is searched in a Unix-like system, that is, a font file that matches the requested font is searched in the system font directory of the embedded device. Specifically, the local font with the highest matching degree is found based on the font name, style, and size. For example, if the request is for the bold style of the Arial font, the Arial Bold font in the local system of the embedded device will be searched. If the requested font is not available in the local system of the embedded device, a similar font can be found to replace it.

[0057] After the font is determined, the specific glyph of the character in the target font is determined based on the encoding unit corresponding to the character. The font file contains a coding table that maps the character encoding to the specific glyph position in the font. The glyph position corresponding to the character in the target font can be found through the coding table. It should be noted that a drawing file, namely a postScript file, can also be generated based on the drawing instructions. All instructions for drawing text, graphics and lines are combined into a postScript file. This file contains page descriptions, font information, drawing instructions and other content. Fonts can also be embedded in postScript files to ensure that the text can be displayed correctly on the target printer or monitor.

[0058] Optionally, generating a drawing instruction corresponding to the character string according to the glyphs corresponding to the respective characters includes:

[0059] According to the target code values corresponding to the characters, sub-drawing instructions corresponding to the characters are generated; and according to the sub-drawing instructions corresponding to the characters, drawing instructions corresponding to the character string are generated.

[0060] For example, assume a target application requests to print the string "Hello" using the Arial font, 12-point size, and black color. A search is performed on the Unix-like system for an Arial font file. Once a matching font file is found, the character encoding of the requested character is mapped to a Unicode encoding. Using the Arial font's cmap table, the Unicode encoding is mapped to a glyph index. For example, 'H' (CP1252:0x48) is mapped to Unicode U+0048, which is then mapped to glyph index 48. This generates a sub-drawing instruction for the 'H' character. All sub-drawing instructions are then combined into a complete string drawing instruction.

[0061] In an embodiment of the present invention, the drawing method provided in the embodiment of the present application can receive a task request sent by a target application; parse a character string from the task request, and read the first encoding unit of each character in turn; when the first encoding unit of the character falls within a first preset encoding interval, merge the first encoding unit and the next encoding unit of the first encoding unit, and determine the glyph corresponding to the character; when the first encoding unit of the character does not fall within the first preset encoding interval, directly determine the glyph corresponding to the character based on the first encoding unit; generate a drawing instruction corresponding to the character string based on the glyph corresponding to each character, and send the drawing instruction to an external device. In an embodiment of the present application, by determining the encoding format of the character based on the interval in which the first encoding unit of the character is located; by converting the encoding format that is not supported by the embedded device, the possibility of garbled characters appearing when the embedded device displays or prints the character string, and the possibility of special characters in the character string being lost or replaced with placeholders can be reduced.

[0062] Optionally, when the first encoding unit of the character falls within a first preset encoding interval, merging the first encoding unit with a next encoding unit of the first encoding unit, and determining the glyph corresponding to the character, includes:

[0063] Step S11: when the first encoding unit of the character falls within a first preset encoding interval, determining a proxy area corresponding to the character according to a conversion rule between a first encoding format corresponding to the first encoding unit and a second encoding format supported by the external device;

[0064] Step S12: merging the first encoding unit and the next encoding unit of the first encoding unit according to the proxy area to determine a target encoding value corresponding to the character;

[0065] Step S13: Determine the glyph corresponding to the character according to the target code value.

[0066] It should be noted that, in the embodiment of the present application, the first encoding format is the UTF-16 encoding format, and the second encoding format is the UTF-32 encoding format. The conversion rule between UTF-16 and UTF-32 refers to the character represented by the UTF-32 encoding format. When the code point corresponding to the character is between U+0000 and U+FFFF, the encoding value of the UTF-32 encoding format is directly represented as the encoding value of the UTF-16 encoding format, that is, UTF-32 encoding is equal to UTF-16 encoding. And when the code point corresponding to the character is greater than U+10000, it is necessary to represent the character according to a proxy pair in the proxy area. The proxy area includes two areas, namely the high proxy code point range (U+D800 to U+DBFF) and the low proxy code point range (U+DC00 to U+DFFF). A surrogate pair consists of two 16-bit units (a high surrogate unit and a low surrogate unit), which belong to the high surrogate code point range (U+D800 to U+DBFF) and the low surrogate code point range (U+DC00 to U+DFFF), respectively. The first preset coding interval refers to the high surrogate code point range in the surrogate area.

[0067] That is to say, when the first code unit of a character falls within the high proxy code point range, it means that the code point of the character is greater than U+10000, and the UTF-32 encoded character actually requires two 16-bit code units to represent it. The first code unit is used as the high proxy unit, and the next code unit is used as the low proxy unit to obtain the proxy pair corresponding to the character. The target code value is the encoding format supported by the external device, such as the UTF-32 encoding format. The surrogate pair is converted to UTF-32 encoding, that is, the two 16-bit code units are converted according to the high proxy code point range and the low proxy code point range to obtain the target code value in the UTF-32 encoding format.

[0068] In an embodiment of the present invention, when the first encoding unit of a character falls within a first preset encoding interval, the proxy area corresponding to the character is determined according to a conversion rule between a first encoding format corresponding to the first encoding unit and a second encoding format supported by an external device; based on the proxy area, the first encoding unit and the next encoding unit of the first encoding unit are merged to determine a target encoding value corresponding to the character; and the glyph corresponding to the character is determined based on the target encoding value. Specifically, in an embodiment of the present invention, two encoding units using the UTF-16 encoding format can be determined as a surrogate pair, and the high surrogate unit and the low surrogate unit in the surrogate pair can be merged to obtain an encoding unit in the UTF-32 encoding format, and then the target encoding value in the UTF-32 encoding format can be obtained, so that embedded devices and external devices can fully identify the target encoding value corresponding to the character, reducing the possibility of garbled characters appearing in displayed and printed character strings.

[0069] Optionally, the proxy area includes the first preset coding interval and the second preset coding interval; and the step S12 of merging the first coding unit and the next coding unit of the first coding unit according to the proxy area to determine the target coding value corresponding to the character includes:

[0070] Step 21: Subtract the first encoding unit of the character from the minimum value of the first preset encoding interval to obtain a first operation result;

[0071] Step 22: Subtract the next coding unit of the first coding unit from the minimum value of the second preset coding interval to obtain a second operation result; the maximum value of the first preset coding interval is less than the minimum value of the second preset coding interval;

[0072] Step 23: Shift the first operation result left by 10 bits to obtain a third operation result;

[0073] Step 24: Determine the target encoding value corresponding to the character according to the second operation result and the third operation result.

[0074] It should be noted that in the UTF-16 encoding, characters in the Supplementary Plane are represented using two 16-bit code units, known as surrogate pairs. Supplementary Plane characters are those in the code point range U+10000 to U+10FFFF. The first preset code interval is the high surrogate code point range, and the second preset code interval is the low surrogate code point range.

[0075] Among them, the first preset coding interval is the high proxy code point range, and the minimum value of the first preset coding interval is U+D800. Subtract U+D800 from the first coding unit of the character to obtain the first operation result. The second preset coding interval is the low proxy code point range, and the minimum value of the second preset coding interval is U+DC00. Subtract U+DC00 from the next coding unit of the first coding unit to obtain the second operation result. Shift the first operation result left by 10 bits, that is, multiply the first operation result and 0x400 (that is, multiply the first operation result by 1024) to obtain the third operation result. Sum the third operation result, the second operation result and 0x10000 to obtain the target code value corresponding to the character, which is also the code point of the character in Unicode.

[0076] For example, there is a character whose first encoding unit is U+D83D, and whose next encoding unit is U+DE00. The first encoding unit U+D83D of the character is subtracted from the minimum value U+D800 of the first preset encoding interval to obtain a first operation result 0x3D (0xD83D-0xD800); the next encoding unit U+DE00 of the first encoding unit is subtracted from the minimum value U+DC00 of the second preset encoding interval to obtain a second operation result 0x200 (0xDE00-0xDC00); the first operation result 0x3D is shifted left by 10 bits to obtain a third operation result 0x3D80 (0x3D×0x400=0x3D×1024); finally, the third operation result, the second operation result, and 0x10000 are summed to obtain the target encoding value 0x13F80 (0x10000+0x3D80+0x200) corresponding to the character.

[0077] In an embodiment of the present invention, a first coding unit of a character is subtracted from the minimum value of a first preset coding interval to obtain a first operation result; a next coding unit of the first coding unit is subtracted from the minimum value of a second preset coding interval to obtain a second operation result; the first operation result is shifted left by 10 bits to obtain a third operation result; the third operation result, the second operation result, and 0x10000 are summed to obtain a target coding value corresponding to the character; so that embedded devices and external devices can determine the glyph corresponding to the character according to the target coding value, thereby reducing the possibility of garbled characters appearing in displayed and printed character strings.

[0078] Optionally, the step S102 of parsing a character string from the task request and sequentially reading the encoding unit of each character includes:

[0079] Step S31: setting an offset and initializing the offset to 0;

[0080] Step S32: when the offset is less than the length of the character string, read a character and a first encoding unit corresponding to the character from the character string according to the offset;

[0081] Step S33: After reading a character and the first encoding unit corresponding to the character, the offset is increased by one until the offset is greater than or equal to the length of the character string, and then the traversal of the character string is stopped.

[0082] The offset is used to determine the position of the currently accessed character in the string. By checking whether the offset is less than the length of the string, the start and end of the traversal are controlled. By gradually increasing the offset, each character in the string is ensured to be accessed in sequence. For example, the string str is "hello" and the string length is 5. The offset starts at 0, which is consistent with the character index of the accessed character. The offset is initialized to offset = 0. First iteration: Check offset < 5 (0 < 5), the condition is met. Read the character "h" and its first encoding unit, update the offset offset = 0 + 1 = 1, and so on, for the next round of iteration, until the offset is equal to the length of the string, completing the traversal of each character in the string.

[0083] In an embodiment of the present invention, an offset is set and initialized to 0; when the offset is less than the length of the string, characters and the first encoding units corresponding to the characters are read from the string according to the offset; each time a character and the first encoding unit corresponding to the character are read, the offset is increased by one until the offset is greater than or equal to the length of the string, at which time the traversal of the string is stopped.

[0084] Optionally, whether the first encoding unit of the character falls within the first preset encoding interval can be determined in the following manner:

[0085] Step S41: determining the encoding format of the characters according to the function name called in the task request;

[0086] Step S42: determining a first encoding unit of the character according to the encoding format of the character;

[0087] Step S43: Determine whether the first encoding unit of the character falls within the first preset encoding interval based on a comparison result between the first encoding unit of the character and the first preset encoding interval.

[0088] It should be noted that the encoding format is determined based on the name of the graphics device interface function called in the task request sent by the target application. Both TextOutA and TextOutW are Windows graphics device interface API functions used to draw text. Their primary difference lies in the encoding format: TextOutA corresponds to ANSI, while TextOutW corresponds to UTF-16LE. Most Windows graphics device interface functions involving string processing have two versions, A (ANSI) and W (Wide, Unicode), ending with A / W in the function name. If an application calls the A version function, the target application automatically performs multibyte-to-Unicode conversion. The compatibility layer, upon recognizing the ANSI encoding format for the function call, converts the A version function call to the W version for processing. Therefore, all characters in the string received by the compatibility layer are encoded in UTF-16. Based on the UTF-16 encoding format, the code unit corresponding to each character is determined to be a 16-bit code value, and supplementary plane characters require two 16-bit code units.

[0089] In an embodiment of the present invention, the encoding format of the character is determined based on the function name called in the task request; the first encoding unit of the character is determined based on the encoding format of the character; and whether the first encoding unit of the character falls within the first preset encoding interval is determined based on the comparison result between the first encoding unit of the character and the first preset encoding interval.

[0090] In summary, the drawing method provided in the embodiment of the present application can receive a task request sent by a target application; parse a character string from the task request, and read the first encoding unit of each character in sequence; when the first encoding unit of a character falls within a first preset encoding interval, merge the first encoding unit and the next encoding unit of the first encoding unit, and determine the glyph corresponding to the character; when the first encoding unit of a character does not fall within the first preset encoding interval, determine the glyph corresponding to the character based on the first encoding unit; generate a drawing instruction corresponding to the character string based on the glyph corresponding to each character, and send the drawing instruction to an external device. In the embodiment of the present application, by determining the encoding format of the character based on the interval in which the first encoding unit of the character is located; by converting the encoding format that is not supported by the embedded device, the possibility of garbled characters appearing when the embedded device displays or prints the character string, and the possibility of special characters in the character string being lost or replaced with placeholders can be reduced.

[0091] Device embodiment

[0092] Reference Figure 2 , shows a structural block diagram of a drawing device of the present invention, the device may specifically include:

[0093] The receiving module 210 is configured to receive a task request sent by a target application; the task request is used to instruct the embedded device to perform a corresponding task using at least one external device;

[0094] A parsing module 220 is configured to parse a character string from the task request and sequentially read the first encoding unit of each character;

[0095] A first determining module 230 is configured to, when a first encoding unit of the character falls within a first preset encoding interval, merge the first encoding unit with a next encoding unit of the first encoding unit and determine a glyph corresponding to the character;

[0096] A second determining module 240 is configured to determine a glyph corresponding to the character according to the first encoding unit if the first encoding unit of the character does not fall within the first preset encoding interval;

[0097] The generating module 250 is configured to generate a drawing instruction corresponding to the character string according to the glyphs corresponding to the characters, and send the drawing instruction to the external device; the drawing instruction is used to control the external device to depict the glyphs of the characters in the character string.

[0098] Optionally, the first determining module includes:

[0099] A first determining submodule is configured to determine, when the first encoding unit of the character falls within a first preset encoding interval, a proxy area corresponding to the character according to a conversion rule between a first encoding format corresponding to the first encoding unit and a second encoding format supported by the external device;

[0100] A second determining submodule is configured to combine the first encoding unit and the next encoding unit of the first encoding unit according to the proxy area to determine a target encoding value corresponding to the character;

[0101] The third determining submodule is configured to determine the glyph corresponding to the character according to the target encoding value.

[0102] Optionally, the second determining submodule includes:

[0103] a first operation module, configured to perform a subtraction operation on the first encoding unit of the character and the minimum value of the first preset encoding interval to obtain a first operation result;

[0104] a second operation module, configured to perform a subtraction operation on the next coding unit of the first coding unit and the minimum value of the second preset coding interval to obtain a second operation result; the maximum value of the first preset coding interval is less than the minimum value of the second preset coding interval;

[0105] A third operation module, configured to shift the first operation result left by 10 bits to obtain a third operation result;

[0106] A determination unit is used to determine the target encoding value corresponding to the character based on the second operation result and the third operation result.

[0107] Optionally, the parsing module includes:

[0108] An initialization module, used for setting an offset and initializing the offset to 0;

[0109] A reading module, configured to read a character and a first encoding unit corresponding to the character from the character string according to the offset when the offset is less than the length of the character string;

[0110] The updating module is configured to increase the offset by one each time a character and the first encoding unit corresponding to the character are read, and stop traversing the character string when the offset is greater than or equal to the length of the character string.

[0111] Optionally, the device further includes:

[0112] An encoding format determination module, configured to determine the encoding format of the character according to the function name called in the task request;

[0113] A coding unit determination module, configured to determine a first coding unit of a character according to a coding format of the character;

[0114] The interval determination module is used to determine whether the first encoding unit of the character falls into the first preset encoding interval according to a comparison result between the first encoding unit of the character and the first preset encoding interval.

[0115] In summary, an embodiment of the present application provides a drawing device that can receive a task request sent by a target application; parse a character string from the task request and read the first encoding unit of each character in sequence; if the first encoding unit of a character falls within a first preset encoding interval, merge the first encoding unit and the next encoding unit of the first encoding unit, and determine the glyph corresponding to the character; if the first encoding unit of a character does not fall within the first preset encoding interval, determine the glyph corresponding to the character based on the first encoding unit; generate a drawing instruction corresponding to the character string based on the glyph corresponding to each character, and send the drawing instruction to an external device. In an embodiment of the present application, by determining the encoding format of a character based on the interval in which the first encoding unit of the character is located; by converting encoding formats that are not supported by the embedded device, the possibility of garbled characters appearing when the embedded device displays or prints a character string, and the possibility of special characters in the character string being lost or replaced with placeholders can be reduced.

[0116] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0117] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0118] Regarding the processor in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method and will not be elaborated here.

[0119] Reference Figure 3 , is a structural block diagram of an electronic device for drawing provided by an embodiment of the present invention. Figure 3 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the drawing method of the aforementioned embodiment.

[0120] The processor may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable devices, transistor logic devices, hardware components, or any combination thereof. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

[0121] The communication bus may include a path for transmitting information between the memory and the communication interface. The communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The fact that only one line is used does not mean that there is only one bus or one type of bus.

[0122] The memory can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or it can be an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0123] The embodiment of the present invention further provides a non-transitory computer-readable storage medium, which, when the instructions in the storage medium are executed by a processor of an electronic device (server or terminal), enables the processor to execute Figure 1 The drawing method shown.

[0124] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0125] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0126] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems) and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0127] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0128] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0129] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0130] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0131] The above describes in detail a drawing method, device, electronic device, and readable storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only intended to help understand the method and core concept of the present invention. At the same time, for those skilled in the art, based on the concept of the present invention, there may be changes in the specific implementation methods and application scope. In summary, the contents of this specification should not be understood as limiting the present invention.

Claims

1. A drawing method, characterized in that: Applied to an embedded device connected to at least one external device, the method includes: receiving a task request sent by a target application; the task request is used to instruct the embedded device to use at least one external device to perform a corresponding task; Parsing a character string from the task request and reading the first encoding unit of each character in sequence; When the first encoding unit of the character falls within a first preset encoding interval, merging the first encoding unit and the next encoding unit of the first encoding unit, and determining a glyph corresponding to the character; If the first encoding unit of the character does not fall within the first preset encoding interval, determining the glyph corresponding to the character according to the first encoding unit; A drawing instruction corresponding to the character string is generated according to the glyphs corresponding to the respective characters, and the drawing instruction is sent to the external device; the drawing instruction is used to control the external device to draw the glyphs of the respective characters in the character string.

2. The method according to claim 1, characterized in that When the first encoding unit of the character falls within the first preset encoding interval, merging the first encoding unit with the next encoding unit of the first encoding unit and determining the glyph corresponding to the character includes: When the first encoding unit of the character falls within a first preset encoding interval, determining a proxy area corresponding to the character according to a conversion rule between a first encoding format corresponding to the first encoding unit and a second encoding format supported by the external device; Merging the first encoding unit and the next encoding unit of the first encoding unit according to the proxy area to determine a target encoding value corresponding to the character; The glyph corresponding to the character is determined according to the target code value.

3. The method according to claim 2, characterized in that The proxy area includes the first preset coding interval and the second preset coding interval; and merging the first coding unit and the next coding unit of the first coding unit according to the proxy area to determine the target coding value corresponding to the character includes: Performing a subtraction operation on the first encoding unit of the character and the minimum value of the first preset encoding interval to obtain a first operation result; performing a subtraction operation on the next coding unit of the first coding unit and the minimum value of the second preset coding interval to obtain a second operation result; the maximum value of the first preset coding interval is less than the minimum value of the second preset coding interval; Shift the first operation result left by 10 bits to obtain a third operation result; Determine the target encoding value corresponding to the character based on the second operation result and the third operation result.

4. The method according to claim 1, wherein The step of parsing a character string from the task request and sequentially reading the first encoding unit of each character includes: Set an offset and initialize the offset to 0; When the offset is less than the length of the character string, reading a character and a first encoding unit corresponding to the character from the character string according to the offset; Each time a character and the first encoding unit corresponding to the character are read, the offset is increased by one until the offset is greater than or equal to the length of the character string, and the traversal of the character string is stopped.

5. The method according to claim 1, wherein The method further comprises: Determining the encoding format of the character according to the function name called in the task request; Determining a first encoding unit of the character according to the encoding format of the character; According to a comparison result between the first encoding unit of the character and the first preset encoding interval, it is determined whether the first encoding unit of the character falls within the first preset encoding interval.

6. A drawing device, characterized in that: Applied to an embedded device connected to at least one external device, the apparatus comprises: A receiving module, configured to receive a task request sent by a target application; the task request is used to instruct the embedded device to perform a corresponding task using at least one external device; A parsing module, configured to parse a character string from the task request and sequentially read the first encoding unit of each character; A first determining module is configured to merge the first encoding unit and the next encoding unit of the first encoding unit when the first encoding unit of the character falls within a first preset encoding interval, and determine a glyph corresponding to the character; a second determining module, configured to determine a glyph corresponding to the character according to the first encoding unit if the first encoding unit of the character does not fall within a first preset encoding interval; The generating module is used to generate a drawing instruction corresponding to the character string according to the glyphs corresponding to the characters, and send the drawing instruction to the external device; the drawing instruction is used to control the external device to draw the glyphs of the characters in the character string.

7. The device according to claim 6, characterized in that The first determining module includes: A first determining submodule is configured to determine, when the first encoding unit of the character falls within a first preset encoding interval, a proxy area corresponding to the character according to a conversion rule between a first encoding format corresponding to the first encoding unit and a second encoding format supported by the external device; A second determining submodule is configured to combine the first encoding unit and the next encoding unit of the first encoding unit according to the proxy area to determine a target encoding value corresponding to the character; The third determining submodule is configured to determine the glyph corresponding to the character according to the target encoding value.

8. The method according to claim 6, characterized in that The second determining submodule includes: a first operation module, configured to perform a subtraction operation on the first encoding unit of the character and the minimum value of the first preset encoding interval to obtain a first operation result; a second operation module, configured to perform a subtraction operation on the next coding unit of the first coding unit and the minimum value of the second preset coding interval to obtain a second operation result; the maximum value of the first preset coding interval is less than the minimum value of the second preset coding interval; A third operation module, configured to shift the first operation result left by 10 bits to obtain a third operation result; A determination unit is used to determine the target encoding value corresponding to the character based on the second operation result and the third operation result.

9. An electronic device, characterized in that: The electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to execute the drawing method according to any one of claims 1 to 5 by one or more processors.

10. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the processor is enabled to execute the drawing method according to any one of claims 1 to 5.