Data encoding method, device and equipment

By encoding the application identifier and application data in the GS1 encoding mode separately and encoding and combining them based on the data structure, the error problems caused by low encoding efficiency and complexity in the prior art are solved, and more efficient and accurate data encoding is achieved.

CN118780308BActive Publication Date: 2024-12-13ARTICLE NUMBERING CENT OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411259232.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2024-12-13
Estimated Expiration
2044-09-10

AI Technical Summary

Technical Problem

When encoding supply chain unit data, the existing GS1 encoding mode has low encoding efficiency and structured input and output problems, which leads to a high probability of error encoding and decoding.

Method used

By obtaining the application identifier and application data in the data to be encoded separately, encoding is performed based on the data structure corresponding to the application identifier, avoiding the conversion of the encoding mode and the use of separators, and directly combining the encoding results.

Benefits of technology

It improves encoding efficiency, reduces the probability of error encoding and error decoding, simplifies encoding complexity, and improves the accuracy and reliability of data encoding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118780308B_ABST
    Figure CN118780308B_ABST
Patent Text Reader

Abstract

The present application provides a data encoding method, device and equipment, which relates to the field of coding identification technology. The data encoding method includes: obtaining data to be encoded, the data to be encoded includes an application identifier and application data; encoding the application identifier to obtain first encoded data; encoding the application data based on the data structure corresponding to the application identifier to obtain second encoded data; and obtaining the encoding result of the data to be encoded according to the first encoded data and the second encoded data. The present application can greatly improve the encoding efficiency and effectively reduce the probability of the occurrence of erroneous encoding and erroneous decoding problems caused by the complexity of encoding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of coding recognition technology, and in particular to a data coding method, device and equipment. Background Art

[0002] At present, in the GS1 system, data carriers usually use Hanxin code, and the encoding mode corresponding to Hanxin code is the GS1 encoding mode. When encoding the relevant data of supply chain units (such as goods, packaging boxes, etc.) through the GS1 encoding mode, the relevant data is first converted into GS1 data containing numbers, characters and symbols, and then the numbers in the GS1 data are encoded using the digital mode, and the characters and symbols in the GS1 data are encoded using the text mode to obtain the Hanxin code corresponding to the GS1 data. Among them, different types of GS1 data are separated by separators.

[0003] However, encoding GS1 data in the above manner has the problem of low encoding efficiency. Summary of the invention

[0004] The present application provides a data encoding method, device and equipment to solve the problem of low encoding efficiency when encoding GS1 data in the current way.

[0005] In a first aspect, the present application provides a data encoding method, comprising: obtaining data to be encoded, the data to be encoded comprising an application identifier and application data; encoding the application identifier to obtain first encoded data; encoding the application data based on a data structure corresponding to the application identifier to obtain second encoded data; and obtaining an encoding result of the data to be encoded based on the first encoded data and the second encoded data.

[0006] Optionally, based on the data structure corresponding to the application identifier, the application data is encoded to obtain second encoded data, including: extracting the target data structure corresponding to the application identifier according to the data structure corresponding to the application identifier, the target data structure does not contain the sub-data structure corresponding to the application identifier; based on the target data structure, the application data is encoded to obtain second encoded data.

[0007] Optionally, based on the target data structure, the application data is encoded to obtain second encoded data, including: if it is determined according to the target data structure that the application data includes data of non-fixed length, obtaining first binary data corresponding to the length of the application data, and obtaining second binary data corresponding to the application data; obtaining second encoded data based on the first binary data and the second binary data; if it is determined according to the target data structure that the application data includes data of fixed length, the second encoded data is obtained as second binary data.

[0008] Optionally, the application data includes data consisting of numbers, and obtaining second binary data corresponding to the application data includes: grouping the numbers in the application data according to a first preset length to obtain multiple groups; if there is no group that does not meet the first preset length among the multiple groups, obtaining third binary data of the second preset length corresponding to the numbers in each group, and determining that the second binary data is data composed of each third binary data; if there is a group that does not meet the first preset length among the multiple groups, obtaining fourth binary data of the second preset length corresponding to the numbers in the group that meets the first preset length, and obtaining fifth binary data of the third preset length corresponding to each number in the group that does not meet the first preset length, and determining that the second binary data is data composed of the fourth binary data and the fifth binary data.

[0009] Optionally, the application data includes data composed of characters and / symbols, and obtaining second binary data corresponding to the application data includes: for each character and / symbol in the application data, obtaining the ASCII code value corresponding to the character and / symbol, and obtaining sixth binary data of a fourth preset length corresponding to the ASCII code value; determining that the second binary data is data composed of each sixth binary data.

[0010] Optionally, encoding the application identifier to obtain first encoded data includes: querying and obtaining a number corresponding to the application identifier; and encoding the number to obtain the first encoded data.

[0011] Optionally, the last digit of the application identifier represents the number of decimal places, and the number is encoded to obtain first encoded data, including: encoding the number to obtain first sub-binary data; encoding the last digit to obtain second sub-binary data; and concatenating the first sub-binary data and the second sub-binary data to obtain first encoded data.

[0012] Optionally, based on the first coded data and the second coded data, an encoding result of the data to be encoded is obtained, including: combining the first coded data and the second coded data in a preset order to obtain combined coded data; determining that the encoding result is data consisting of a start symbol, the combined coded data, and a terminator, the start symbol is located at the starting position of the combined coded data, and the terminator is located at the ending position of the combined coded data.

[0013] In a second aspect, the present application provides a data encoding device, comprising:

[0014] The first acquisition module is used to obtain the data to be encoded, and the data to be encoded includes an application identifier and application data; the first encoding module is used to encode the application identifier to obtain first encoded data; the second encoding module is used to encode the application data based on the data structure corresponding to the application identifier to obtain second encoded data; the second acquisition module is used to obtain the encoding result of the data to be encoded based on the first encoded data and the second encoded data.

[0015] Optionally, the second encoding module is specifically used to: extract the target data structure corresponding to the application identifier according to the data structure corresponding to the application identifier, the target data structure does not contain the sub-data structure corresponding to the application identifier; based on the target data structure, encode the application data to obtain second encoded data.

[0016] Optionally, when the second encoding module is used to encode the application data based on the target data structure to obtain the second encoded data, it is specifically used to: if it is determined according to the target data structure that the application data includes data of non-fixed length, obtain the first binary data corresponding to the length of the application data, and obtain the second binary data corresponding to the application data; obtain the second encoded data based on the first binary data and the second binary data; if it is determined according to the target data structure that the application data includes data of fixed length, the second encoded data is the second binary data.

[0017] Optionally, the application data includes data composed of numbers. When the second encoding module is used to obtain the second binary data corresponding to the application data, it is specifically used to: group the numbers in the application data according to a first preset length to obtain multiple groups; if there is no group that does not meet the first preset length among the multiple groups, obtain the third binary data of the second preset length corresponding to the numbers in each group, and determine that the second binary data is data composed of each third binary data; if there is a group that does not meet the first preset length among the multiple groups, obtain the fourth binary data of the second preset length corresponding to the numbers in the group that meets the first preset length, and obtain the fifth binary data of the third preset length corresponding to each number in the group that does not meet the first preset length, and determine that the second binary data is data composed of the fourth binary data and the fifth binary data.

[0018] Optionally, the application data includes data composed of characters and / symbols. When the second encoding module is used to obtain the second binary data corresponding to the application data, it is specifically used to: obtain the ASCII code value corresponding to each character and / symbol in the application data, and obtain the sixth binary data of the fourth preset length corresponding to the ASCII code value; determine that the second binary data is data composed of each sixth binary data.

[0019] Optionally, the first encoding module is specifically used to: query and obtain a number corresponding to the application identifier; and encode the number to obtain first encoded data.

[0020] Optionally, the last digit of the application identifier represents the number of decimal places. When the first encoding module is used to encode the number to obtain the first encoded data, it is specifically used to: encode the number to obtain the first sub-binary data; encode the last digit to obtain the second sub-binary data; and concatenate the first sub-binary data and the second sub-binary data to obtain the first encoded data.

[0021] Optionally, the second acquisition module is specifically used to: combine the first encoded data and the second encoded data in a preset order to obtain combined encoded data; determine that the encoding result is data consisting of a start symbol, the combined encoded data, and a terminator, the start symbol is located at the starting position of the combined encoded data, and the terminator is located at the ending position of the combined encoded data.

[0022] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;

[0023] Memory stores computer-executable instructions;

[0024] The processor executes the computer-executable instructions stored in the memory to implement the data encoding method as described in the first aspect of the present application.

[0025] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer program instructions are stored. When the computer program instructions are executed, the data encoding method described in the first aspect of the present application is implemented.

[0026] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the data encoding method described in the first aspect of the present application when the computer program is executed.

[0027] The data encoding method, device and equipment provided by the present application obtain data to be encoded, the data to be encoded includes an application identifier and application data; encode the application identifier to obtain first encoded data; encode the application data based on the data structure corresponding to the application identifier to obtain second encoded data; and obtain the encoding result of the data to be encoded according to the first encoded data and the second encoded data. In the present application, considering the data structure corresponding to the application identifier in the data to be encoded, the application identifier and the application data in the data to be encoded are encoded separately, instead of combining the application identifier and the application data into a string and encoding them together as in the current technology, and there is no need to convert the encoding mode or use a separator, so the encoding efficiency can be greatly improved, and the probability of erroneous encoding and erroneous decoding problems caused by encoding complexity can be effectively reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0029] Figure 1 A schematic diagram of the current coding efficiency for encoding different numbers of application identifier data segments;

[0030] Figure 2 A schematic diagram of an application scenario provided for an embodiment of the present application;

[0031] Figure 3 A flowchart of a data encoding method provided in one embodiment of the present application;

[0032] Figure 4 A flowchart of a data encoding method provided by another embodiment of the present application;

[0033] Figure 5 A schematic diagram of a process of encoding data to be encoded provided by an embodiment of the present application;

[0034] Figure 6 A schematic diagram of encoding efficiency for encoding different numbers of application identifier data segments provided by an embodiment of the present application;

[0035] Figure 7 A schematic diagram of the structure of a data encoding device provided in one embodiment of the present application;

[0036] Figure 8 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0038] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0039] The Global Article Numbering Group (GS1) is a neutral, non-profit international organization that develops, manages and maintains the most widely used global unified identification system (i.e., GS1 system), effectively promoting global trade circulation and supply chain efficiency. At present, in the GS1 system, GS1 coding is used, and the data carrier usually uses Hanxin code, and the coding mode corresponding to Hanxin code is the GS1 coding mode. Among them, Hanxin code is a standard QR code system; GS1 coding is a standard coding, especially in the fields of manufacturing, retail, logistics, supply chain and global trade, GS1 coding is the data basis and common business language for the informatization of these fields. The information compiled by GS1 coding is the relevant data of the supply chain unit. In actual applications, each supply chain unit (such as goods, such as packaging boxes, such as manufacturer addresses, etc.) may require a lot of data, such as manufacturer code, product code, batch, single product code, production date, shelf life, unit price, packaging box code, etc. The design principle of GS1 coding is to use an open, unified, transparent and reasonable coding method to represent these data.

[0040] Each GS1 code is composed of a series of data segments (application identification segments) connected in sequence. For each data segment, the specific data information is represented by the application identifier (AI) and the application data (Data) guided by the application identifier. The application identifier (AI) is used to represent the basic meaning of the application data in the data segment. For example, the application data stores the product barcode code, product batch number, product serial number, production date, shelf life, unit price, quantity, specification, packaging box or logistics unit code, address, etc. The application data is used to represent specific data. Application data can be represented by standard rules, such as the code or number uniformly assigned by GS1, such as the barcode code of retail goods or the global location code (GLN) code of the address, where the barcode code of retail goods can also be understood as the international product code (EAN13) or the global trade item number (GTIN); it can also be a data encoding form that can be customized by the industry, region, and enterprise, such as the batch number and serial number of the product; at the same time, some relevant data encoding forms that are internationally accepted can also be used, such as production date, packaging date, delivery date, size information, price information, quantity information, etc. Moreover, the GS1 encoding standard leaves enough space for necessary standardization of relevant codes. Table 1 takes some application identifiers in the GS1 general specification, the content identified by the application identifier, and the corresponding data structure as an example. It should be noted that Table 1 is only an example of some application identifiers, not a limitation on application identifiers.

[0041] Table 1

[0042]

[0043] Referring to Table 1, the first sub-data structure in the data structure (before "+", such as N2, N3 and N4) indicates the length of the application identifier (AI) (i.e., the number of digits); the second sub-data structure after "+" (such as N18, N14 and X..20, etc.) indicates the format of the application data (Data), where N indicates the number of digits, N18 indicates that the application data is a fixed length of 18 digits, N14 indicates that the application data is a fixed length of 14 digits, N6 indicates that the application data is a fixed length of 6 digits, and N2 indicates that the application data is a fixed length of 2 digits. , N13 indicates that the application data is a fixed-length 13-digit number, N..6 indicates a variable-length number with a maximum length of 6, N..8 indicates a variable-length number with a maximum length of 8; n indicates a decimal place; X indicates characters and / symbols, X..20 indicates a variable-length character and / symbol with a maximum length of 20, X..28 indicates a variable-length character and / symbol with a maximum length of 28, X..30 indicates a variable-length character and / symbol with a maximum length of 30, X..17 indicates a variable-length character and / symbol with a maximum length of 17, and X..12 indicates a variable-length character and / symbol with a maximum length of 12. The values ​​in brackets [ ] are optional. If there are only year and month, "day" must be filled in with "00" unless otherwise specified. The fourth digit of the application identifier indicates the number of decimal places (implied decimal point position), for example, for application identifier 310n, 3100 indicates the net weight in kilograms without a decimal part; 3102 indicates the net weight in kilograms with two decimal places.

[0044] GS1 encoding mode complies with the provisions of GS1 general specifications, supports the encoding and decoding of all application identifiers (AI) in GS1 general specifications, and provides development space for the increase of application identifiers in the future. It can efficiently encode and represent GS1 data, and provide space for the structured input and structured output of GS1 data, so that Hanxin code can truly play the role of offline data recording, and access data structure instead of just a piece of text or binary data. Generally speaking, GS1 encoding mode is an exclusive information encoding mode. When encoding the relevant data of supply chain units (such as goods, packaging boxes, etc.) through GS1 encoding mode, the relevant data is first converted into GS1 data containing numbers, characters and symbols, and then the numbers in GS1 data are encoded in digital mode, and the characters and symbols in GS1 data are encoded in text mode to obtain the Hanxin code corresponding to GS1 data. Among them, different types of GS1 data are separated by separators. Specifically, GS1 encoding mode is used to encode GS1 data defined by GS1 specifications. The GS1 data structure defined by the GS1 system is as follows: AI1Data1…AI i Data i <fnc1>…AI p Data p ,i=1,2,…p

[0045] Among them, AI i Indicates the application identifier defined by the GS1 specification; Data i Indicates AI defined by GS1 specifications i The corresponding application data; <fnc1>It is a delimiter used to separate fixed-length data from non-fixed-length data in GS1 data. It can be understood that each GS1 data segment has a keyword AI i ,Data i Is with keyword AI i The associated value. According to GS1 specifications, all GS1 data strings of predefined length (i.e. fixed length) should be placed first, followed by all GS1 data strings of non-predefined length (i.e. non-fixed length). If more than two non-predefined length strings are used at the end of the entire string, a separator should be added between the two strings. <fnc1>. Separator <fnc1>Immediately following a non-predefined length data segment, it is followed by the GS1 Application Identifier for the next data segment. However, if a non-predefined length data segment is the last data segment to be encoded, it should not be used <fnc1>The Hanxin Code uses the extended digital mode and text mode to encode GS1 data. The GS1 start character is 1110 0001 and the GS1 end character is 1111 1111. When encoding in the GS1 encoding mode, the GS1 data segment is merged into a delimiter. <fnc1>If you do not need to add separators <fnc1>, the entire GS1 data is encoded using the standard Hanxin code digital mode and / or text mode; if there are two or more groups, the first two adjacent groups separated by a separator are selected <fnc1>GS1 data segment groups separated by a separator <fnc1>The encoding mode at the beginning is digital mode, and the separator <fnc1>As a number, the expansion code is "1111101000", and then the separator is added by padding "1111101000" to the encoded bit string. <fnc1>The corresponding code is encoded into the binary coded data, and the digital mode encoding continues until the end of the next group or the first character other than 0 to 9 is encountered. If the initial encoding scheme is text mode, the text mode is first terminated with the text mode terminator, and then the digital mode indicator "0001" is added to the delimiter. <fnc1>Start numeric mode before encoding and fill with separators <fnc1>The corresponding "1111101000" code continues to be encoded in the digital mode until the end of the next group. After all the groups are encoded, the GS1 terminator 1111 1111 is added.

[0046] In one example, the GS1 data is (01)03453120000011(17)191125(10)ABCD1234, and the GS1 data is encoded using the current GS1 encoding mode. Specifically, the GS1 start symbol 1110 0001 is used to indicate the start of the GS1 encoding mode; the GS1 data can be decomposed into three data segments, namely (01)03453120000011, (17)191125 and (10)ABCD1234. Since no separator is required between different data segments in the GS1 data, <fnc1>Therefore, the GS1 data can be merged to obtain a group: 01034531200000111719112510ABCD1234; for this group, it can be divided into two strings "01034531200000111719112510" and "ABCD1234", which are encoded in digital mode and Text mode respectively: (1) For "01034531200000111719112510", the encoding process is: divide the string into groups of 3 digits: 010 345 312 000 001 117 191 125 10, starting with a digital pattern, the pattern start character is 0001, and the pattern terminator is selected as 1111111110, each group of numbers is converted to the corresponding binary: 010 is converted to 0000001010, 345 is converted to 0101011001, 312 is converted to 0100111000, 000 is converted to 0000000000, 001 is converted to 0000000001, 117 is converted to 0001110101, 191 is converted to 0010111111, 125 is converted to 0001111101 and 10 is converted to 0000001010, and then the pattern terminator 1111111110 is appended, so that the encoding result of "01034531200000111719112510" is 0001 0000001010 0101011001 01001110000000000000 0000000001 0001110101 0010111111 0001111101 0000001010 1111111110; (2) For "ABCD1234", convert it to Text mode for encoding. The mode start character is 0010. Encode each character in the string using the text mode, convert A to 001010, B to 001011, C to 001100, D to 001101, 1 to 000001, 2 to 000010, 3 to 000011, and 4 to 000100. Then append the mode terminator 111111. The resulting encoding of "ABCD1234" is 0010 001010001011 001100 001101 000001 000010 000011 000100 111111.Finally, the encoding result of the GS1 data is 1110 0001 0001 0000001010 0101011001 0100111000 00000000000000000000001 0001110101 0010111111 0001111101 0000001010 1111111110 0010 001010001011 001100 001101 000001 000010 000011 000100 111111 1111 1111.

[0047] In another example, the GS1 data is (01)03453120000011(17)191125(10)ABCD1234(21)10, and the GS1 data is encoded using the current GS1 encoding mode. Specifically, the GS1 start symbol 1110 0001 is used to indicate the start of the GS1 encoding mode. The GS1 data contains 4 data segments, and a separator is added between the data segment (10)ABCD1234 and the data segment (21)10. <fnc1>Therefore, after merging the GS1 data, you can use the separator <fnc1>Divide the GS1 data into two groups: 01034531200000111719112510ABCD1234 <fnc1>2110. Referring to the previous example, the first set of GS1 data "01034531200000111719112510ABCD1234" is encoded using the current GS1 encoding mode, and the encoding result is 0001 0000001010 0101011001 0100111000 0000000000 00000000010001110101 0010111111 0001111101 0000001010 1111111110 0010 001010 001011001100 001101 000001 000010 000011 000100 111111. For the second set of GS1 data" <fnc1>2110", because the encoding mode of the data segment (10) ABCD1234 in the first set of GS1 data is text mode, and the separator <fnc1>The characters after are 0 to 9. Therefore, the encoding process of the second set of GS1 data is: select the digital mode start character as 0001 and the end character as 11111111011. <fnc1>It should be encoded as 1111101000. Continue the digital mode encoding for 2110, and the encoding result is 0011010011 00000000000. Finally, the encoding result of the GS1 data is 1110 0001 00010000001010 0101011001 0100111000 0000000000 0000000001 0001110101 00101111110001111101 0000001010 1111111110 0010 001010 001011 001100 001101 000001000010 000011 000100 111111 0001 1111101000 0011010011 0000000000 111111111011111111111.

[0048] For example, Figure 1 is a schematic diagram of the current coding efficiency for encoding different numbers of application identifier data segments, such as Figure 1 As shown, when GS1 data is encoded by the current GS1 encoding mode, based on the statistical results of encoding a single application identifier data segment, a combination of 2 application identifier data segments, a combination of 3 application identifier data segments, a combination of 4 application identifier data segments, a combination of 5 application identifier data segments, a combination of 6 application identifier data segments, a combination of 7 application identifier data segments, a combination of 8 application identifier data segments, a combination of 9 application identifier data segments, and a combination of 10 application identifier data segments, it can be obtained. Figure 1 The coding efficiency shown in Table 2 is based on the Figure 1 The statistical results obtained.

[0049] Table 2

[0050]

[0051] refer to Figure 1 When encoding the GS1 data using the current GS1 encoding mode, if multiple data are not pure numbers, it is necessary to switch from digital mode to text mode. If there are enough numbers behind, it is necessary to switch from text mode to digital mode again, and it is also necessary to separate different types of GS1 data using separators. Therefore, encoding the GS1 data using the current GS1 encoding mode has the problem of low encoding efficiency. In addition, there are also problems with the structured input and output of GS1 data, and the need for technicians to be very familiar with the GS1 encoding data rules in order to be able to encode correctly, and the purpose of encapsulating the complexity of the GS1 system encoding into the Hanxin code system is not achieved.

[0052] Based on the above problems, the present application provides a data encoding method. Taking into account that a structured coding method can be adopted, based on the data structure corresponding to the application identifier in the data to be encoded, the application identifier and application data in the data to be encoded are encoded separately, without the need to convert the encoding mode or use separators. Therefore, the encoding efficiency can be greatly improved, and the probability of erroneous encoding and decoding problems caused by encoding complexity can be effectively reduced.

[0053] In the following, the application scenarios of the solutions provided in this application are first described with examples.

[0054] Figure 2 This is a schematic diagram of an application scenario provided by an embodiment of the present application. Figure 2 As shown, taking the supply chain unit as a commodity as an example, the commodity data includes, for example, the commodity code, production date, shelf life and unit price, etc. According to the data encoding method provided in this application, the encoding result of the commodity data can be obtained, and the encoding result is the Hanxin code. The Hanxin code can be printed and affixed to the commodity, and the commodity data can be obtained by scanning the Hanxin code on the commodity using a terminal device (such as a mobile phone, not shown in the figure). It should be noted that Figure 2 This is only a schematic diagram of an application scenario provided by the embodiment of the present application. Figure 2 does not limit the equipment included in Figure 2 The positional relationship between the devices is limited.

[0055] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0056] Figure 3 This is a flow chart of a data encoding method provided by an embodiment of the present application. The data encoding method can be executed by software and / or hardware devices. For example, the hardware device can be a data encoding device, and the data encoding device can be an electronic device or a processing chip in the electronic device. Figure 3 As shown, the method of the embodiment of the present application includes:

[0057] S301. Obtain data to be encoded, where the data to be encoded includes an application identifier and application data.

[0058] In the embodiment of the present application, the data to be encoded may be input by a user to the electronic device executing the embodiment of the present method, or may be sent by other devices to the electronic device executing the embodiment of the present method. Exemplarily, the data to be encoded is the GS1 data corresponding to the commodity data, and the data to be encoded may be decomposed into multiple data segments (for example, represented by Segment), and different data segments represent different commodity data. Each data segment contains only an application identifier (AI) and the application data (Data) corresponding to the application identifier, for example, Segment i =AI i Data i , i=1,2,…k, where k represents decomposing the data to be encoded into k data segments; each data segment can be understood as a key-value pair with an application identifier as a key and application data as a value. The application identifier can be a 2-bit, 3-bit or 4-bit number used to identify the meaning (content) and data structure of the data corresponding to the application identifier. Specifically, if the data to be encoded is (01)06954606200026(10)A001(253)695460620001918004-2004, the data to be encoded can be decomposed into three data segments, namely (01)06954606200026, (10)A001 and (253)695460620001918004-2004. Refer to Table 1, where, for data segment (01) 06954606200026, 01 is an application identifier, indicating a global trade item code, and 06954606200026 is application data corresponding to the global trade item code, that is, data segment (01) 06954606200026 indicates that the global trade item code is: 06954606200026; for data segment (10) A001, 10 is an application identifier, indicating a batch number, and A001 is application data corresponding to the batch number, that is, data segment (10) A002. 01 indicates that the batch number is: A001; for the data segment (253) 695460620001918004-2004, 253 is the application identifier, indicating the global document type code, and 695460620001918004-2004 is the application data corresponding to the global document type code, that is, the data segment (253) 695460620001918004-2004 indicates that the global document type code is: 695460620001918004-2004.

[0059] Optionally, whether the application data is fixed-length data or non-fixed-length data can be determined based on the data structure corresponding to the application identifier. For example, referring to Table 1, the application identifier is 01, which indicates the global trade item code. The data structure corresponding to the application identifier 01 is N2+N14, where N2 indicates that the length of the application identifier 01 is 2, and N14 indicates that the length of the application data corresponding to the application identifier 01 is a fixed-length 14-digit number. The application identifier is 10, which indicates the batch number. The data structure corresponding to the application identifier 10 is N2+X..20, where N2 indicates that the length of the application identifier 10 is 2, and X..20 indicates that the length of the application data corresponding to the application identifier 10 is a non-fixed-length character and / symbol, with a maximum length of 20.

[0060] S302: Encode the application identifier to obtain first encoded data.

[0061] It can be understood that the embodiment of the present application encodes the application identifier and the application data separately, rather than combining the application identifier and the application data into a string and encoding them together as in the current technology. For example, the application identifier can be directly encoded to obtain the first encoded data, or the application identifier can be converted into a number and the number can be encoded to obtain the first encoded data. For specific information on how to encode the application identifier to obtain the first encoded data, please refer to the subsequent embodiments.

[0062] S303. Encode the application data based on the data structure corresponding to the application identifier to obtain second encoded data.

[0063] Exemplarily, referring to Table 1, the data structure corresponding to the application identifier can be queried and obtained. According to the data structure corresponding to the application identifier, it can be determined whether the application data is fixed-length data or non-fixed-length data. If the application data is non-fixed-length data, the length of the application data needs to be encoded separately, such as converted into 8-bit binary data. Referring to the example of step S301, the data to be encoded is, for example, (01) 06954606200026 (10) A001 (253) 695460620001918004-2004. For each of the three data segments (01) 06954606200026, (10) A001 and (253) 695460620001918004-2004, the application data can be encoded based on the data structure corresponding to the application identifier to obtain the second encoded data. For how to encode the application data based on the data structure corresponding to the application identifier to obtain the second encoded data, please refer to the subsequent embodiments.

[0064] S304: Obtain an encoding result of the data to be encoded according to the first encoded data and the second encoded data.

[0065] In this step, after obtaining the first encoded data and the second encoded data, the first encoded data and the second encoded data can be combined in a preset order to form encoded data corresponding to the data to be encoded, and a GS1 start symbol is added to the starting position of the encoded data, and a GS1 terminator is added to the ending position of the encoded data to obtain the encoding result of the data to be encoded.

[0066] The data encoding method provided in the embodiment of the present application obtains data to be encoded, and the data to be encoded includes an application identifier and application data; encodes the application identifier to obtain first encoded data; based on the data structure corresponding to the application identifier, encodes the application data to obtain second encoded data; and obtains the encoding result of the data to be encoded according to the first encoded data and the second encoded data. In the embodiment of the present application, considering the data structure corresponding to the application identifier in the data to be encoded, the application identifier and the application data in the data to be encoded are encoded separately, instead of combining the application identifier and the application data into a string and encoding them together as in the current technology, and there is no need to convert the encoding mode or use a separator, so the encoding efficiency can be greatly improved, and the probability of the occurrence of erroneous encoding and erroneous decoding problems caused by encoding complexity can be effectively reduced.

[0067] Figure 4 This is a flow chart of a data encoding method provided by another embodiment of the present application. Based on the above embodiment, the present application embodiment further illustrates the data encoding method. Figure 4 As shown, the method of the embodiment of the present application may include:

[0068] S401. Obtain data to be encoded, where the data to be encoded includes an application identifier and application data.

[0069] The detailed description of this step can be found in Figure 3 The relevant description of S301 in the illustrated embodiment will not be repeated here.

[0070] In the embodiment of the present application, Figure 3 The step S302 may further include the following two steps S402 and S403:

[0071] S402: Query and obtain the number corresponding to the application identifier.

[0072] Exemplarily, based on Table 1, Table 3 shows the content identified by a part of the application identifier, the corresponding data structure, whether the decimal point position encoding is required, the number corresponding to the application identifier, and the binary encoding corresponding to the number. It should be noted that Table 3 is only an example of the relevant information of a part of the application identifier, and is not a limitation on the relevant information of the application identifier. Table 3 can be queried according to the application identifier to obtain the number corresponding to the application identifier. For example, the application identifier is 01 and the corresponding number is 2.

[0073] Table 3

[0074]

[0075] S403: Encode the serial number to obtain first encoded data.

[0076] For example, after obtaining the serial number corresponding to the application identifier, the serial number may be encoded to obtain the first encoded data. For example, the serial number corresponding to the application identifier 01 is 2, and 2 is converted into an 8-bit binary code 00000010, that is, the first encoded data is 00000010.

[0077] Optionally, the last digit of the application identifier represents the number of decimal places, and the number is encoded to obtain the first encoded data, which may include: encoding the number to obtain first sub-binary data; encoding the last digit to obtain second sub-binary data; and concatenating the first sub-binary data and the second sub-binary data to obtain the first encoded data.

[0078] Exemplarily, referring to Table 3, the application identifier is, for example, 3101, and the last digit 1 represents 1 decimal place, that is, the decimal point position encoding is required, then the number 25 corresponding to the application identifier 3101 is encoded to obtain the first sub-binary data 00011001, and the last digit 1 of the application identifier 3101 is converted into, for example, a 4-bit binary code 0001 to obtain the second sub-binary data, and the second sub-binary data is added to the first sub-binary data to obtain the first encoded data 00011001 0001.

[0079] In the embodiment of the present application, Figure 3 The step S303 may further include the following two steps S404 and S405:

[0080] S404. Extract a target data structure corresponding to the application identifier according to the data structure corresponding to the application identifier, wherein the target data structure does not include a sub-data structure corresponding to the application identifier.

[0081] It can be understood that, since the serial number corresponding to the application identifier is encoded instead of the application identifier, the target data structure corresponding to the application identifier can be extracted according to the data structure corresponding to the application identifier, that is, the sub-data structure corresponding to the application identifier is deleted from the data structure corresponding to the application identifier to obtain the target data structure corresponding to the application identifier. For example, the data to be encoded is (01)06954606200026(10)A001(253)695460620001918004-2004, and Table 3 can be queried to obtain that the data structure corresponding to the application identifier 01 is N2+N14, the data structure corresponding to the application identifier 10 is N2+X..20, and the data structure corresponding to the application identifier 253 is N3+N13+[X..17]. According to the data structure corresponding to the application identifier, the target data structure corresponding to the application identifier is extracted. The target data structure corresponding to the application identifier 01 is N14, which does not include the sub-data structure N2 corresponding to the application identifier; the target data structure corresponding to the application identifier 10 is X0..20, which does not include the sub-data structure N2 corresponding to the application identifier; the target data structure corresponding to the application identifier 253 is N13+[X0..17], which does not include the sub-data structure N3 corresponding to the application identifier. Among them, for the target data structure, "Nm" means that the application data consists of fixed m digital data; "Xm" means that the application data consists of fixed m GS1 characters and / or symbol data; "Nm1..m2" means that the application data consists of variable-length (from m1 to m2) digital data; "Xm1..m2" means that the application data consists of variable-length (from m1 to m2) GS1 characters and / or symbol data.

[0082] S405. Encode the application data based on the target data structure to obtain second encoded data.

[0083] Exemplarily, after the target data structure corresponding to the application identifier is extracted, the application data may be encoded based on the target data structure corresponding to the application identifier to obtain second encoded data.

[0084] Optionally, encoding the application data based on the target data structure to obtain second encoded data may include: if it is determined according to the target data structure that the application data includes data of non-fixed length, obtaining first binary data corresponding to the length of the application data, and obtaining second binary data corresponding to the application data; obtaining second encoded data based on the first binary data and the second binary data; if it is determined according to the target data structure that the application data includes data of fixed length, obtaining the second encoded data as second binary data.

[0085] Exemplarily, if it is determined according to the target data structure that the application data includes data of non-fixed length, the length of the application data (i.e., the actual length, not the format length) is converted into, for example, an 8-bit binary code, to obtain the first binary data. If the length is 0, the corresponding first binary data also needs to be obtained. If it is determined according to the target data structure that the application data includes data of fixed length, it is not necessary to process the length of the application data. Referring to the example of step S404, according to the target data structure N14 corresponding to the application identifier 01, it can be determined that the application data includes data of fixed length, therefore, the application data 06954606200026 is encoded to obtain the second encoded data. According to the target data structure X0..20 corresponding to the application identifier 10, it can be determined that the application data includes data of non-fixed length, therefore, the length (i.e., 4) of the application data A001 is encoded to obtain the first binary data, and the application data A001 is encoded to obtain the second binary data, and the first binary data is added to the starting position of the second binary data to obtain the second encoded data.

[0086] Optionally, the application data includes data consisting of numbers, and obtaining second binary data corresponding to the application data may include: grouping the numbers in the application data according to a first preset length to obtain multiple groups; if there is no group that does not meet the first preset length among the multiple groups, obtaining third binary data of the second preset length corresponding to the numbers in each group, and determining that the second binary data is data composed of each third binary data; if there is a group that does not meet the first preset length among the multiple groups, obtaining fourth binary data of the second preset length corresponding to the numbers in the group that meets the first preset length, and obtaining fifth binary data of the third preset length corresponding to each number in the group that does not meet the first preset length, and determining that the second binary data is data composed of the fourth binary data and the fifth binary data.

[0087] Exemplarily, the first preset length is, for example, 3 bits, the second preset length is, for example, 8 bits, and the third preset length is, for example, 4 bits. Referring to the example of step S404, the data to be encoded is, for example, (01)06954606200026(10)A001(253)695460620001918004-2004. Taking the application identifier as 01 and the application data as 06954606200026 as an example, the application data includes data composed of digits. The digits in the application data 06954606200026 are grouped into groups of 3 digits each, and 5 digits including 069, 546, 062, 000, and 26 are obtained. groups; if there is a group that does not meet the first preset length among the five groups, then obtain the 10-bit fourth binary data corresponding to the numbers in each group that meets the first preset length (i.e., the group containing 069, 546, 062, and 000), and obtain the 4-bit fifth binary data corresponding to each number (i.e., 2 and 6) in the group that does not meet the first preset length (i.e., the group containing 26), and determine that the second binary data is data composed of the fourth binary data and the fifth binary data, that is, the second binary data is 0001000101 10001000100000111110 00000000000 0010 0110. If there is no group that does not meet the first preset length among the multiple groups, obtain the third binary data of the second preset length corresponding to the numbers in each group, and determine that the second binary data is data composed of each third binary data.

[0088] Optionally, the application data includes data composed of characters and / or symbols, and obtaining the second binary data corresponding to the application data may include: for each character and / or symbol in the application data, obtaining the ASCII code (a standard character encoding system) value corresponding to the character and / or symbol, and obtaining sixth binary data of a fourth preset length corresponding to the ASCII code value; and determining that the second binary data is data composed of each sixth binary data.

[0089] Exemplarily, the fourth preset length is 8 bits, and referring to the example of step S404, the data to be encoded is (01)06954606200026(10)A001(253)695460620001918004-2004. Taking the application identifier as 10 and the application data as A001 as an example, the application data includes data composed of characters. For each character in the application data A001, the ASCII code value corresponding to each character is obtained, and the 8-bit sixth binary data corresponding to the ASCII code value is obtained, and the second binary data is determined to be data composed of each sixth binary data, that is, the second binary data is 01000001 0011000000110000 00110001.

[0090] In the embodiment of the present application, Figure 3 The step S304 may further include the following two steps S406 and S407:

[0091] S406: Combine the first coded data and the second coded data according to a preset order to obtain combined coded data.

[0092] Exemplarily, the preset order is the order of the application identifier and the application data in the data to be encoded. Referring to the example of step S404, the data to be encoded is, for example, (01)06954606200026(10)A001(253)695460620001918004-2004, and the order of each application identifier and each application data in the data to be encoded (i.e., the preset order) can be determined. After obtaining the first encoded data corresponding to each application identifier and the second encoded data corresponding to each application data, each first encoded data and each second encoded data can be combined according to the preset order to obtain the combined encoded data.

[0093] S407: Determine that the encoding result is data consisting of a start symbol, combined encoded data, and a terminator, wherein the start symbol is located at a start position of the combined encoded data, and the terminator is located at a terminal position of the combined encoded data.

[0094] Exemplarily, the start symbol is, for example, the GS1 start symbol 1110 0001, and the end symbol is, for example, the GS1 end symbol 11111111. After obtaining the combined coded data, the GS1 start symbol 1110 0001 can be added to the start position of the combined coded data, and the GS1 end symbol 1111 1111 can be added to the end position of the combined coded data, thereby obtaining the encoding result of the data to be encoded.

[0095] The data encoding method provided in the embodiment of the present application comprises the following steps: obtaining data to be encoded, the data to be encoded comprises an application identifier and application data; querying and obtaining a number corresponding to the application identifier, encoding the number, and obtaining first encoded data; extracting a target data structure corresponding to the application identifier according to a data structure corresponding to the application identifier, wherein the target data structure does not contain a sub-data structure corresponding to the application identifier; encoding the application data based on the target data structure, and obtaining second encoded data; combining the first encoded data and the second encoded data in a preset order, and obtaining the combined encoded data; determining that the encoding result is data composed of a start symbol, the combined encoded data, and a terminator, wherein the start symbol is located at the starting position of the combined encoded data, and the terminator is located at the ending position of the combined encoded data. In the embodiment of the present application, considering the data structure corresponding to the application identifier in the data to be encoded, the number and the application data corresponding to the application identifier in the data to be encoded are encoded separately, and there is no need to convert the encoding mode or use a separator, especially the application identifier which needs at least 16-32 bits to be represented in the current technology is directly converted into the encoded data corresponding to the number represented by fewer bits (such as 8 bits), so that the encoding efficiency can be greatly improved, and the probability of the occurrence of the error encoding and error decoding problems caused by the encoding complexity can be effectively reduced.

[0096] Based on the above embodiments, Figure 5 , through specific examples, the data encoding method provided in the embodiment of the present application is described in detail. Figure 5 A schematic diagram of a process for encoding data to be encoded provided by an embodiment of the present application. Figure 5 As shown, the commodity data includes a global trade item code, a batch number, and a global document type code. According to the data encoding method provided in the embodiment of the present application, the data to be encoded corresponding to the commodity data is (01) 06954606200026 (10) A001 (253) 695460620001918004-2004, and the data to be encoded can be decomposed into three data segments, namely (01) 06954606200026, (10) A001, and (253) 695460620001918004-2004. Among them, the data segment (01) 06954606200026 indicates that the global trade item code of the product is 06954606200026, the data segment (10) A001 indicates that the batch number of the product is A001, and the data segment (253) 695460620001918004-2004 indicates that the global document type code of the product is 695460620001918004-2004.

[0097] Encode each data segment. Specifically, first, encode the number 2 corresponding to the application identifier 01, and obtain the first encoded data as 00000010; encode the number 4 corresponding to the application identifier 10, and obtain the first encoded data as 00000100; encode the number 21 corresponding to the application identifier 253, and obtain the first encoded data as 00010101. Then, according to the data structure corresponding to the application identifier, extract the target data structure corresponding to the application identifier, and obtain the target data structure corresponding to the application identifier 01 as N14, the target data structure corresponding to the application identifier 10 as X0..20, and the target data structure corresponding to the application identifier 253 as N13+[X0..17]; based on the target data structure, encode the application data 06954606200026, wherein the number in the application data 06954606200026 is The words are grouped into groups of 3 bits each, and 5 groups are obtained, including 069, 546, 062, 000 and 26 respectively; 069 is encoded as 0001000101, 546 is encoded as 1000100010, 062 is encoded as 0000111110, 000 is encoded as 0000000000, 2 is encoded as 0010, and 6 is encoded as 0110, that is, the second encoded data is 0001000101 10001000100000111110 00000000000 0010 0110; Based on the target data structure, the application data A001 is encoded. Since the application data A001 is data of non-fixed length, it is necessary to encode the length of the application data A001 (i.e., 4), and obtain the encoded data corresponding to the length as 00000100, and obtain the ASCII code value corresponding to each character in the application data A001, and obtain the 8-bit binary data corresponding to each ASCII code value, and obtain 01000001 00110000 00110000 00110001, so that the second encoded data is 00000100 01000001 00110000 00110000 00110001;Based on the target data structure, the application data 695460620001918004-2004 is encoded. First, the first 13 bits of the fixed-length data 6954606200019 of the application data are encoded in groups of 3 bits to obtain the encoded data 1010110111 01110011001001101100 0000000001 1001. Then the remaining 10 bits of non-fixed-length data 18004-2004 are encoded to obtain the encoded data corresponding to the length 10 of 18004-2004 as 00001010, and the ASCII code value corresponding to each character in 18004-2004 is obtained. The 8-bit binary data corresponding to each ASCII code value is obtained, and the encoded data is 0011000100111000 00110000 00110000 00110100 00101101 00110010 00110000 0011000000110100, so the second encoded data is 1010110111 0111001100 1001101100 00000000011001 00001010 00110001 00111000 00110000 00110100 00101101 0011001000110000 00110000 00110100. The first coded data and the second coded data are combined in a preset order to obtain combined coded data, a GS1 start symbol 1110 0001 is added to the starting position of the combined coded data, and a GS1 terminator 1111 1111 is added to the ending position of the combined coded data, so that the encoding result of the data to be encoded is: 1110 0001 00000010 0001000101 1000100010 0000111110 0000000000 0010 011000000100 00000100 01000001 00110000 00110000 001100001 00010101 10101101110111001100 1001101100 000000001 1001 00001010 00110001 00111000 001100000110000 00110100 00101101 00110010 00110000 00110000 00110100 1111 1111. ;

[0098] Based on the above embodiment, the data decoding method corresponding to the data encoding method provided in the embodiment of the present application is described in detail below through specific examples. Figure 5 Taking the encoding result of the data to be encoded as an example, when decoding the encoding result, the following steps may be included:

[0099] Step 1. Obtain the encoding result of the data to be encoded: 1110 0001 00000010 00010001011000100010 0000111110 00000000000 0010 0110 00000100 00000100 0100000100110000 00110000 00110001 00010101 1010110111 0111001100 100110110000000000001 1001 00001010 00110001 00111000 00110000 00110000 0011010000101101 00110010 00110000 00110000 00110100 1111 1111.

[0100] Step 2: Read the GS1 start code 1110 0001 from the encoding result.

[0101] Step 3: Decode the encoding results after the GS1 start code 1110 0001 in sequence, wherein the number corresponding to the application identifier and the data structure corresponding to the application identifier can be obtained by querying Table 3. Specifically, the following steps may be included:

[0102] (1) Obtain 00000010 in the encoding result, corresponding to number 2, query Table 3, obtain the application identifier corresponding to number 2 is 01 and the data structure is N2+N14; according to the data structure, obtain the encoding result corresponding to the 14-digit number for decoding, that is, decode 0001000101 as 069, 1000100010 as 546, 0000111110 as 062, 0000000000 as 000, 0010 as 2, and 0110 as 6, so as to obtain AI1Data1=(01)06954606200026.

[0103] (2) Continue to decode 00000100 and get the number 4. Look up Table 3 and get the application identifier 10 and data structure N2+X..20 corresponding to number 4. According to the data structure, continue to decode 00000100 and get the number of ASCII code values ​​of non-fixed length 4. Get the encoding results corresponding to the 4 ASCII code values ​​and decode them, that is, 0100000100110000 00110000 00110001 is decoded into A001, thereby obtaining AI2Data2=(10)A001.

[0104] (3) Continue to decode 00010101 and get the number 21. Look up Table 3 and get the application identifier 253 and data structure (N3+N13+X..17) corresponding to number 21. According to the data structure, get the encoding result corresponding to the 13-digit number for decoding, that is, 1010110111 0111001100 1001101100 0000000001 1001 is decoded to 6954606200019. Continue to decode 00001010 and get the number of ASCII code values ​​of non-fixed length is 10. Get the encoding result corresponding to 10 ASCII code values ​​for decoding, that is, 00110001 00111000 00110000 001100000110100 00101101 00110010 00110000 00110000 00110100 decodes to 18004-2004, resulting in AI3Data3=(253)695460620001918004-2004.

[0105] (4) Continue to obtain the GS1 terminator 1111 1111, indicating the end of decoding.

[0106] Step 4: Combine the obtained AI1Data1, AI2Data2 and AI3Data3 to obtain the decoded GS1 data: (01)06954606200026(10)A001(253)695460620001918004-2004.

[0107] The data decoding method provided in the embodiment of the present application is simple and convenient to decode, and can effectively reduce the probability of erroneous decoding problems caused by coding complexity.

[0108] Based on the above embodiments, Figure 6 A schematic diagram of the coding efficiency for encoding different numbers of application identifier data segments provided by an embodiment of the present application, such as Figure 6 As shown, when GS1 data encoding is performed by the data encoding method provided in the embodiment of the present application, based on the statistical results of encoding a single application identifier data segment, a combination of 2 application identifier data segments, a combination of 3 application identifier data segments, a combination of 4 application identifier data segments, a combination of 5 application identifier data segments, a combination of 6 application identifier data segments, a combination of 7 application identifier data segments, a combination of 8 application identifier data segments, a combination of 9 application identifier data segments, and a combination of 10 application identifier data segments, it can be obtained. Figure 6 The coding efficiency shown is Figure 1 Compared with the coding efficiencies shown in Table 4, the data coding method provided in the embodiment of the present application can effectively improve the coding efficiency. The horizontal axis represents different numbers of application identifier data segments, and the vertical axis represents the coding efficiency (bits / character). Figure 6 The obtained statistical results are compared with those in Table 1. The average coding efficiency can be improved by 21%-31% through the data coding method provided in the embodiment of the present application.

[0109] Table 4

[0110]

[0111] Based on the above embodiments, the data encoding method provided in the embodiments of the present application optimizes the encoding of each application identifier and the encoding of application data separately compared to the current GS1 encoding mode of the Hanxin Code, which can significantly improve the encoding efficiency and provide room for improvement for the use of Chinese in future applications. In particular, not only can each AI data segment be encoded and decoded separately, but the corresponding fields and actual data can also be extracted in the process, helping applications, systems, databases and software to realize direct data interfaces during the encoding and decoding process.

[0112] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0113] Figure 7 A structural diagram of a data encoding device provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the data encoding device 700 of the embodiment of the present application includes: a first acquisition module 701, a first encoding module 702, a second encoding module 703 and a second acquisition module 704. Among them:

[0114] The first acquisition module 701 is used to acquire the data to be encoded, where the data to be encoded includes an application identifier and application data.

[0115] The first encoding module 702 is used to encode the application identifier to obtain first encoded data.

[0116] The second encoding module 703 is used to encode the application data based on the data structure corresponding to the application identifier to obtain second encoded data.

[0117] The second acquisition module 704 is used to obtain the encoding result of the data to be encoded according to the first encoded data and the second encoded data.

[0118] In some embodiments, the second encoding module 703 can be specifically used to: extract the target data structure corresponding to the application identifier according to the data structure corresponding to the application identifier, and the target data structure does not contain the sub-data structure corresponding to the application identifier; based on the target data structure, encode the application data to obtain second encoded data.

[0119] Optionally, when the second encoding module 703 is used to encode the application data based on the target data structure to obtain the second encoded data, it can be specifically used to: if it is determined according to the target data structure that the application data includes data of non-fixed length, obtain the first binary data corresponding to the length of the application data, and obtain the second binary data corresponding to the application data; obtain the second encoded data based on the first binary data and the second binary data; if it is determined according to the target data structure that the application data includes data of fixed length, the second encoded data is obtained as the second binary data.

[0120] Optionally, the application data includes data consisting of numbers. When the second encoding module 703 is used to obtain the second binary data corresponding to the application data, it can be specifically used to: group the numbers in the application data according to a first preset length to obtain multiple groups; if there is no group that does not meet the first preset length among the multiple groups, obtain the third binary data of the second preset length corresponding to the numbers in each group, and determine that the second binary data is data composed of each third binary data; if there is a group that does not meet the first preset length among the multiple groups, obtain the fourth binary data of the second preset length corresponding to the numbers in the group that meets the first preset length, and obtain the fifth binary data of the third preset length corresponding to each number in the group that does not meet the first preset length, and determine that the second binary data is data composed of the fourth binary data and the fifth binary data.

[0121] Optionally, the application data includes data composed of characters and / symbols. When the second encoding module 703 is used to obtain the second binary data corresponding to the application data, it can be specifically used to: obtain the ASCII code value corresponding to each character and / symbol in the application data, and obtain the sixth binary data of the fourth preset length corresponding to the ASCII code value; determine that the second binary data is data composed of each sixth binary data.

[0122] In some embodiments, the first encoding module 702 may be specifically used to: query and obtain the serial number corresponding to the application identifier; and encode the serial number to obtain first encoded data.

[0123] Optionally, the last digit of the application identifier represents the number of decimal places. When the first encoding module 702 is used to encode the number to obtain the first encoded data, it can be specifically used to: encode the number to obtain the first sub-binary data; encode the last digit to obtain the second sub-binary data; concatenate the first sub-binary data and the second sub-binary data to obtain the first encoded data.

[0124] In some embodiments, the second acquisition module 704 can be specifically used to: combine the first encoded data and the second encoded data in a preset order to obtain combined encoded data; determine that the encoding result is data consisting of a start symbol, the combined encoded data, and a terminator, the start symbol is located at the starting position of the combined encoded data, and the terminator is located at the ending position of the combined encoded data.

[0125] The device of the embodiment of the present application can be used to execute the technical solution of any of the above-mentioned method embodiments, and its implementation principle and technical effect are similar, which will not be repeated here.

[0126] Figure 8 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Figure 8 As shown, the electronic device 800 may include: at least one processor 801 and a memory 802 .

[0127] The memory 802 is used to store programs. Specifically, the programs may include program codes, and the program codes include computer-executable instructions.

[0128] The memory 802 may include a high-speed random access memory (Random Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage.

[0129] The processor 801 is used to execute the computer-executable instructions stored in the memory 802 to implement the data encoding method described in the aforementioned method embodiment. Among them, the processor 801 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. Specifically, when implementing the data encoding method described in the aforementioned method embodiment, the electronic device may be, for example, an electronic device with processing functions such as a terminal and a server.

[0130] Optionally, the electronic device 800 may further include a communication interface 803. In a specific implementation, if the communication interface 803, the memory 802 and the processor 801 are implemented independently, the communication interface 803, the memory 802 and the processor 801 may be interconnected through a bus and communicate with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.

[0131] Optionally, in a specific implementation, if the communication interface 803, the memory 802 and the processor 801 are integrated on a chip, the communication interface 803, the memory 802 and the processor 801 can communicate through an internal interface.

[0132] The present application also provides a computer-readable storage medium, in which computer program instructions are stored. When a processor executes the computer program instructions, the above data encoding method is implemented.

[0133] The present application also provides a computer program product, including a computer program, which implements the above data encoding method when executed by a processor.

[0134] The computer-readable storage medium mentioned above may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk. The readable storage medium may be any available medium that can be accessed by a general or special purpose computer.

[0135] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in a dedicated integrated circuit. Of course, the processor and the readable storage medium can also exist as discrete components in the data encoding device.

[0136] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A data encoding method, characterized in that: include: Acquire data to be encoded, where the data to be encoded includes an application identifier and application data; Encoding the application identifier to obtain first encoded data; Encoding the application data based on the data structure corresponding to the application identifier to obtain second encoded data; Obtaining an encoding result of the data to be encoded according to the first encoded data and the second encoded data; The step of encoding the application data based on the data structure corresponding to the application identifier to obtain second encoded data includes: Extracting, according to the data structure corresponding to the application identifier, a target data structure corresponding to the application identifier, wherein the target data structure does not include a sub-data structure corresponding to the application identifier; Based on the target data structure, encoding the application data to obtain the second encoded data; The step of encoding the application data based on the target data structure to obtain the second encoded data includes: If it is determined according to the target data structure that the application data includes data of non-fixed length, obtaining first binary data corresponding to the length of the application data, and obtaining second binary data corresponding to the application data; obtaining the second encoded data according to the first binary data and the second binary data; If it is determined according to the target data structure that the application data includes data of a fixed length, the second encoded data obtained is the second binary data.

2. The data encoding method according to claim 1, characterized in that: The application data includes data composed of digits, and obtaining the second binary data corresponding to the application data includes: Grouping the numbers in the application data according to a first preset length to obtain a plurality of groups; If there is no group that does not meet the first preset length in the multiple groups, obtain third binary data of the second preset length corresponding to the numbers in each of the groups, and determine that the second binary data is data composed of each of the third binary data; If there are groups among the multiple groups that do not meet the first preset length, obtain the fourth binary data of the second preset length corresponding to the numbers in the group that meets the first preset length, and obtain the fifth binary data of the third preset length corresponding to each number in the group that does not meet the first preset length, and determine that the second binary data is data composed of the fourth binary data and the fifth binary data.

3. The data encoding method according to claim 1, characterized in that: The application data includes data composed of characters and / or symbols, and the obtaining of second binary data corresponding to the application data includes: For each character and / or symbol in the application data, obtain the ASCII code value corresponding to the character and / or the symbol, and obtain sixth binary data of a fourth preset length corresponding to the ASCII code value; The second binary data is determined to be data composed of each of the sixth binary data.

4. The data encoding method according to any one of claims 1 to 3, characterized in that: The step of encoding the application identifier to obtain first encoded data includes: Query and obtain the number corresponding to the application identifier; The number is encoded to obtain the first encoded data.

5. The data encoding method according to claim 4, characterized in that: The last digit of the application identifier represents the number of decimal places, and the encoding of the number to obtain the first encoded data includes: Encoding the number to obtain first sub-binary data; Encoding the last digit to obtain second sub-binary data; The first sub-binary data and the second sub-binary data are concatenated to obtain the first encoded data.

6. The data encoding method according to any one of claims 1 to 3, characterized in that: The step of obtaining the encoding result of the data to be encoded according to the first encoded data and the second encoded data includes: Combining the first coded data and the second coded data in a preset order to obtain combined coded data; The encoding result is determined to be data consisting of a start symbol, the combined encoded data, and a terminator, wherein the start symbol is located at a start position of the combined encoded data, and the terminator is located at a terminator position of the combined encoded data.

7. A data encoding device, characterized in that: include: A first acquisition module, used to acquire data to be encoded, wherein the data to be encoded includes an application identifier and application data; A first encoding module, used for encoding the application identifier to obtain first encoded data; A second encoding module, used for encoding the application data based on the data structure corresponding to the application identifier to obtain second encoded data; A second acquisition module, used for obtaining an encoding result of the data to be encoded according to the first encoded data and the second encoded data; The second encoding module is specifically used to: extract a target data structure corresponding to the application identifier according to the data structure corresponding to the application identifier, wherein the target data structure does not include a sub-data structure corresponding to the application identifier; Based on the target data structure, encoding the application data to obtain the second encoded data; When the second encoding module is used to encode the application data based on the target data structure to obtain the second encoded data, it is specifically used to: if it is determined according to the target data structure that the application data includes data of non-fixed length, obtain first binary data corresponding to the length of the application data, and obtain second binary data corresponding to the application data; obtain the second encoded data based on the first binary data and the second binary data; if it is determined according to the target data structure that the application data includes data of fixed length, obtain the second encoded data as the second binary data.

8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the data encoding method according to any one of claims 1 to 6.