Data encoding and decoding method, device, computer device and storage medium
By adding specific separators during the conversion from decimal numbers to binary numbers, the offset problem of decimal number strings during encoding and decoding is solved, ensuring accurate identification of data boundaries and accurate decoding.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI BILIBILI TECH CO LTD
- Filing Date
- 2023-12-28
- Publication Date
- 2026-07-07
Smart Images

Figure CN117811699B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data encoding and decoding method, apparatus, computer equipment, and storage medium. Background Technology
[0002] Encoding refers to the process of converting information from one form to another, while decoding is the reverse process. In existing technology, numbered information such as phone numbers and user IDs can be represented by fixed-length decimal digits. However, since computer systems can only process binary data, this type of numbered information represented by decimal digits is converted into binary numbers when processed by a computer system. The process of converting decimal numbers to binary is also a form of encoding, and converting binary to decimal can be seen as the corresponding decoding.
[0003] The inventors discovered that when several fixed-length decimal digits are sequentially linked to form a number string, if the starting position of each digit is unknown (e.g., a segment is truncated, or a digit is lost), it becomes impossible to determine the start and end positions of each digit in the string. For example, a number string composed of multiple digits of length 3 is: ...1234523... Since the starting position of the digit "1234523" is unknown, its possible configurations are as follows: 1.
[123]
[452] [3..]; 2. [..1]
[234]
[523] ;
[0006] 3. [.12]
[345] [23.].
[0007] Since the number "1234523" can exist in any of the three cases mentioned above, the decoded number information may be offset when decoding a number string containing such numbers. Furthermore, if the decimal number string is converted to binary, even more complex offset problems may arise during decoding.
[0008] Therefore, how to encode the number string composed of decimal data so that there will be no offset problem during decoding has become an urgent problem to be solved. Summary of the Invention
[0009] In view of this, a data encoding and decoding method, apparatus, computer device, and computer-readable storage medium are provided to solve the above problems.
[0010] This application provides a data encoding method, the method comprising:
[0011] Obtain data to be encoded, the data to be encoded including numbering information, the numbering information including at least one number represented by a decimal number;
[0012] According to the preset encoding mapping table, each decimal number in the numbering information is converted into the corresponding initial binary number in turn to obtain the initial binary number group. The encoding mapping table records the mapping relationship between each decimal number 0 to 9 and the corresponding initial binary number.
[0013] A preset separator is concatenated to the left of the highest bit or the right of the lowest bit of the initial binary number group to generate target encoded data. The separator includes M groups of identical binary identifier numbers. Both the initial binary number and the binary identifier number are composed of N binary digits. The binary identifier number has (N-1) binary numbers 0 or 1, where N is an integer greater than or equal to 4 and M is an integer greater than or equal to 2.
[0014] Wherein, when the binary identifier number has (N-1) binary 0s, the initial binary number does not have (N-1) binary 0s;
[0015] When the binary identifier number has (N-1) binary 1s, the initial binary number does not have (N-1) binary 1s.
[0016] Optionally, the separator consists of two identical sets of binary identifier numbers, and both the initial binary number and the binary identifier number consist of four binary digits.
[0017] Optionally, when the separator is 11101110, 11011101, 10111011, or 01110111, the initial binary number corresponding to the decimal digits 0-9 is any 10 binary numbers in the first set, which includes the following 12 binary numbers:
[0018] 0000, 0001, 0010, 0011, 0100, 0101, 0110, 1000, 1001, 1010, 1100, 1111.
[0019] Optionally, when the separator is 00010001, 00100010, 01000100, or 10001000, the initial binary number corresponding to the decimal digits 0-9 is any 10 binary numbers in the second set, which includes the following 12 binary numbers:
[0020] 0000, 0011, 0101, 0110, 0111, 1001, 1010, 1011, 1100, 1101, 1110, 1111.
[0021] Optionally, the separator is 11101110, and the initial binary numbers corresponding to the decimal numbers 0 to 9 are: 0000, 0001, 0010, 0011, 0100, 0101, 0110, 1000, 1001, 1010.
[0022] This application also provides a data decoding method, the method comprising:
[0023] Obtain the data to be decoded, which is obtained by encoding multiple data to be encoded using the data encoding method described above;
[0024] Detect the separator from the data to be decoded;
[0025] The data before and after the separator is decoded according to the preset encoding mapping table to obtain the decoding result. The encoding mapping table records the mapping relationship between the decimal numbers 0 to 9 and the corresponding initial binary numbers.
[0026] This application also provides a data encoding device, the data encoding device comprising:
[0027] An acquisition module is used to acquire data to be encoded, the data to be encoded including numbering information, the numbering information including at least one number represented by a decimal number;
[0028] The encoding module is used to convert each decimal number in the numbering information into a corresponding initial binary number according to a preset encoding mapping table, so as to obtain an initial binary number group. The encoding mapping table records the mapping relationship between each decimal number 0 to 9 and the corresponding initial binary number.
[0029] The splicing module is used to splice a preset separator to the left of the highest bit or the right of the lowest bit of the initial binary number group to generate target encoded data. The separator includes M groups of identical binary identifier numbers. Both the initial binary number and the binary identifier number are composed of N binary digits. The binary identifier number has (N-1) binary numbers 0 or 1, where N is an integer greater than or equal to 4 and M is an integer greater than or equal to 2.
[0030] Wherein, when the binary identifier number has (N-1) binary 0s, the initial binary number does not have (N-1) binary 0s;
[0031] When the binary identifier number has (N-1) binary 1s, the initial binary number does not have (N-1) binary 1s.
[0032] This application also provides a data decoding device, the data decoding device comprising:
[0033] The acquisition module is used to acquire the data to be decoded, which is obtained by encoding multiple data to be encoded by the data encoding method described above.
[0034] The detection module is used to detect the separator identifier from the data to be decoded;
[0035] The decoding module is used to decode the data before the separator and / or the data after the separator according to a preset encoding mapping table to obtain the decoding result. The encoding mapping table records the mapping relationship between decimal numbers 0 to 9 and their corresponding initial binary numbers.
[0036] This application also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described method.
[0037] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0038] The data encoding method of this application involves acquiring data to be encoded, which includes numbering information, including at least one number represented by a decimal digit. Each decimal digit in the numbering information is sequentially converted into a corresponding initial binary number according to a preset encoding mapping table, resulting in an initial binary number group. The encoding mapping table records the mapping relationship between each decimal digit 0-9 and its corresponding initial binary number. A preset separator is concatenated to the left of the most significant bit or the right of the least significant bit in the initial binary number group to generate target encoded data. By using this data encoding method, by encoding decimal digits into specific binary numbers and adding specific separators to identify the boundaries of different data to be encoded during the encoding process, the target encoded data is decoded without any offset after the decimal digits are encoded into binary numbers. Attached Figure Description
[0039] Figure 1 This is a schematic diagram illustrating the application environment of one embodiment of the data encoding method of this application;
[0040] Figure 2 A flowchart of one embodiment of the data encoding method described in this application;
[0041] Figure 3 This is a flowchart of one embodiment of the data decoding method described in this application;
[0042] Figures 4a-4d This is a schematic diagram of the offset of the detected 8-bit data in one embodiment of this application;
[0043] Figure 5 This is a program block diagram of one embodiment of the data encoding device described in this application;
[0044] Figure 6 This is a program block diagram of one embodiment of the data encoding device described in this application;
[0045] Figure 7 A schematic diagram of the hardware structure of a computer device for performing a data encoding or data decoding method provided in an embodiment of this application. Detailed Implementation
[0046] The advantages of this application are further illustrated below with reference to the accompanying drawings and specific embodiments.
[0047] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0048] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The singular forms “a,” “the,” and “the” as used in this disclosure and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0049] It should be understood that although the terms first, second, third, etc., may be used in this disclosure to describe various information, such information should not be limited to these terms. These terms are used only to distinguish information of the same type from one another. For example, without departing from the scope of this disclosure, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0050] In the description of this application, it should be understood that the numerical labels before the steps do not indicate the order of the steps, but are only used to facilitate the description of this application and to distinguish each step, and therefore should not be construed as a limitation of this application.
[0051] The following is a definition of the terminology used in this application:
[0052] Bit: A unit of binary numbers. One bit refers to one binary digit, and each binary digit can be either 0 or 1.
[0053] Information bit: A bit containing (number) information.
[0054] Offset confusion: refers to the incorrect identification of information due to positional offset of a sequence of symbols. For example, […][abca][bcab][cabd][…] is originally composed of several fixed-length actual contents […], [abca], [bcab], [cabd], […] concatenated. However, after offsetting three positions to the right, it can be distinguished as […abc], [abca], [bcab], [d…], where abca appears both before and after the offset. This kind of confusion caused by offset is called offset confusion.
[0055] Figure 1 This illustration shows a schematic diagram of an application scenario provided by an embodiment of this application.
[0056] In an exemplary embodiment, the system of this application environment may include a terminal device 10 and a server 20. The terminal device 10 and the server 20 are connected via a wireless or wired network. The terminal device 10 includes, but is not limited to, smartphones, tablets, laptops, and desktop computers. The server 20 may be a rack server, blade server, tower server, or cabinet server (including standalone servers or server clusters composed of multiple servers). The network may include various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, and / or proxy devices. The network may also include physical links, such as coaxial cable links, twisted-pair cable links, fiber optic links, and combinations thereof and / or the like.
[0057] The following will provide several embodiments within the aforementioned exemplary application environment to illustrate the data encoding scheme in this application. See also... Figure 2 This is a flowchart illustrating a data encoding method according to an embodiment of this application. The data encoding method of this application is applied in a computer device. It should be noted that the flowchart in this method embodiment is not intended to limit the order of execution steps. As can be seen from the figure, the data encoding method provided in this embodiment includes:
[0058] Step S20: Obtain the data to be encoded, the data to be encoded includes numbering information, the numbering information includes at least one number represented by a decimal number.
[0059] Specifically, the numbering information can be information represented using decimal numbers, such as telephone numbers or user IDs.
[0060] In this embodiment, when the data to be encoded includes multiple numbering information, the number of numbers contained in each numbering information can be the same or different.
[0061] Step S21: According to the preset encoding mapping table, each decimal number in the numbering information is converted into the corresponding initial binary number in turn to obtain the initial binary number group. The encoding mapping table records the mapping relationship between each decimal number 0 to 9 and the corresponding initial binary number.
[0062] Step S22: A preset separator is concatenated to the left of the highest bit or the right of the lowest bit of the initial binary number group to generate target encoded data. The separator includes M groups of identical binary identifier numbers. Both the initial binary number and the binary identifier number are composed of N binary digits. The binary identifier number has (N-1) binary numbers 0 or 1, where N is an integer greater than or equal to 4 and M is an integer greater than or equal to 2.
[0063] Wherein, when the binary identifier number has (N-1) binary 0s, the initial binary number does not have (N-1) binary 0s;
[0064] When the binary identifier number has (N-1) binary 1s, the initial binary number does not have (N-1) binary 1s.
[0065] Specifically, when the data to be encoded includes multiple encoded information, each number can be encoded sequentially. In this embodiment, when encoding each number in the numbering information, the decimal number is converted into a fixed-length (N) initial binary number according to the mapping relationship between the decimal numbers 0-9 and their corresponding initial binary numbers recorded in the encoding mapping table. After encoding all the numbers in the numbering information, an initial binary number group can be obtained. The conversion process for encoding each number can be denoted as T.
[0066] As an example, consider a numbering information X consisting of n numbers. in After conversion according to the encoding mapping table, an encoded string X of length (n*N) bits can be obtained. nNbit (The initial binary number group), i.e. X nNbit=T(X) in ).
[0067] In this embodiment, when encoding the number information in the data to be encoded, a separator is additionally defined to identify the boundaries of different number information. This separator can be inserted after encoding a number information, or inserted before encoding a number information.
[0068] As an example, in the case of number information X in Encode the string to obtain an (n*N) bit encoded string X. nNbit Then, you can encode string X nNbit The separator is concatenated to the left of the most significant bit or the right of the least significant bit to obtain the final encoded string X. out (The target encoded data), wherein:
[0069] X out =[separator][X] nNbit ] or X out =[X nNbit [Separator], X out The length is (n*N+M*N) bits.
[0070] In one exemplary embodiment, the separator consists of two identical sets of binary identifier numbers, wherein both the initial binary number and the binary identifier number consist of four binary digits, i.e., M=2 and N=4.
[0071] In an exemplary implementation, when N=4, the binary identifier number can be any one of the following eight binary numbers, wherein the eight binary numbers are as follows:
[0072] 0001, 0010, 0100, 1000, 1110, 1101, 1011, 0111.
[0073] In an exemplary implementation, when N=5, the binary identifier number can be any one of the following 2N=10 binary numbers, wherein the 10 binary numbers are as follows:
[0074] 00001, 00010, 00100, 01000, 10000, 11110, 11101, 11011, 10111, 01111.
[0075] Similarly, when N=6, the binary identifier can be any one of 2N=12 binary identifiers, where the 12 binary identifiers are as follows:
[0076] 000001, 000010, 000100, 001000, 010000, 100000, 111110, 111101, 111011, 110111, 101111, 011111.
[0077] In an exemplary implementation, when M=2 and N=4, if the binary identifier number in the separator has three binary 1s, then the separator can be 11101110, 11011101, 10111011, or 01110111. In this case, since none of the initial binary numbers have three binary 1s, that is, the initial binary number can have zero binary 1s, one binary 1, two binary 1s, or four binary 1s. Therefore, the initial binary number corresponding to the decimal digits 0-9 can be any 10 binary numbers from the first set consisting of all possible values of the initial binary number.
[0078] The first set includes the following 12 binary numbers:
[0079] 0000, 0001, 0010, 0011, 0100, 0101, 0110, 1000, 1001, 1010, 1100, 1111.
[0080] In another embodiment, when M=2 and N=4, if the binary number in the separator has three zeros, then the separator can be 00010001, 00100010, 01000100, or 10001000. In this case, since none of the initial binary numbers have three zeros, that is, the initial binary number can have zero zeros, one zero, two zeros, or four zeros. Therefore, the initial binary number corresponding to the decimal digits 0-9 can be any 10 binary numbers from the second set consisting of all possible values of the initial binary number.
[0081] The second set includes the following 12 binary numbers:
[0082] 0000, 0011, 0101, 0110, 0111, 1001, 1010, 1011, 1100, 1101, 1110, 1111.
[0083] In an exemplary embodiment, when the separator is 11101110, the binary numbers corresponding to the decimal numbers 0 to 9 are sequentially: 0000, 0001, 0010, 0011, 0100, 0101, 0110, 1000, 1001, 1010, that is, the encoding mapping table is as follows:
[0084] Decimal numbering 0 1 2 3 4 5 6 7 8 9 Binary numbering 0000 0001 0010 0011 0100 0101 0110 1000 1001 1010
[0085] In other embodiments, the binary numbers corresponding to the decimal numbers 0 to 9 can also have other correspondences, such as decimal number 0 corresponding to binary number 0001, decimal number 1 corresponding to binary number 0000, etc.
[0086] The data encoding method in this embodiment involves acquiring data to be encoded, which includes numbering information, including at least one number represented by a decimal digit. Each decimal digit in the numbering information is sequentially converted into a corresponding initial binary number according to a preset encoding mapping table, resulting in an initial binary number group. The encoding mapping table records the mapping relationship between each decimal digit from 0 to 9 and its corresponding initial binary number. A preset separator is then appended to the left of the most significant bit or the right of the least significant bit of the initial binary number group to generate the target encoded data. By using this data encoding method, and by encoding decimal digits into specific binary numbers, and by adding specific separators to identify the boundaries of different data to be encoded during the encoding process, the target encoded data is decoded without any offset after the decimal digits are encoded into binary numbers.
[0087] See Figure 3 This is a flowchart illustrating a data decoding method according to an embodiment of this application. The data decoding method of this application is applied in a computer device. It should be noted that the flowchart in this method embodiment is not intended to limit the order of execution steps. As can be seen from the figure, the data decoding method provided in this embodiment includes:
[0088] Step S30: Obtain the data to be decoded, which is obtained by encoding multiple data to be encoded using the data encoding method described above.
[0089] Specifically, the data to be decoded is represented by binary numbers, and the data to be decoded is obtained by encoding multiple data to be encoded using the data encoding method described above, that is, the data to be decoded is obtained by encoding multiple numbering information.
[0090] Step S31: Detect the separator identifier from the data to be decoded.
[0091] Specifically, the separator is the data in the data to be decoded used to identify the boundaries of different numbering information.
[0092] In this embodiment, when the separator identifier is detected from the data to be decoded, the data between two adjacent separator identifiers can be used as an initial binary number group corresponding to a numbering information.
[0093] As an example, if the separator is 11101110, then the data between two adjacent 11101110 can be used as an initial binary number group corresponding to a numbering information. That is, the first data after the currently detected separator 11101110 to the first data before the next detected separator 11101110 can be used as an initial binary number group corresponding to a numbering information.
[0094] Step S32: Decode the data before the separator and / or the data after the separator according to the preset encoding mapping table to obtain the decoding result. The encoding mapping table records the mapping relationship between the decimal numbers 0 to 9 and the corresponding initial binary numbers.
[0095] Specifically, the encoding mapping table is the encoding mapping table in the above-described data encoding method embodiment, and will not be described again in this embodiment.
[0096] In this embodiment, since the encoding mapping table records the mapping relationship between decimal numbers 0 to 9 and their corresponding initial binary numbers, the binary number can be converted to the corresponding decimal number by performing a reverse mapping based on the mapping relationship between decimal numbers 0 to 9 and their corresponding initial binary numbers recorded in the encoding mapping table.
[0097] As an example, suppose the data between two adjacent separators is Y. 4bit In the case of Y 4bit After performing the inverse mapping, the decoding result Y can be obtained. out , i.e. Y out =T -1 (Y 4bit ).
[0098] As an example, if only one separator is detected, the data before or after the separator will be decoded according to the encoding mapping table to obtain the decoding result.
[0099] Specifically, when decoding the data before or after the separator identifier, the data is divided into multiple initial binary numbers according to a fixed length (N). Then, each initial binary number is mapped back to its corresponding decimal number according to the encoding mapping table.
[0100] To facilitate proof that the target encoded data (data to be decoded) obtained after encoding the data to be encoded using the data encoding method in this application will not have an offset problem, this application only needs to prove that the detected separator can only be a separator and cannot be caused by other situations.
[0101] The following example uses 10 binary data from the set K = {0000,0001,0010,0011,0100,0101,0110,1000,1001,1010}, corresponding to the decimal digits 0-9, as an example to illustrate why the separator 11101110 can only be a separator and cannot be any other data.
[0102] The following explanation covers two scenarios:
[0103] 1. The detected separator (11101110) contains k characters from the separator, where k > 0. That is, 11101110 is formed by concatenating the characters from the separator with the characters from the binary number.
[0104] a) When k=7, if 11101110 is composed of the first 7 bits (1110111) of the separator and a bit number a, i.e., a1110111 = 11101110, this situation is impossible because the corresponding binary numbers are different; if 11101110 is composed of the last 7 bits (1101110) of the separator and a bit number a, i.e., 1101110a = 11101110, this situation is also impossible because the corresponding binary numbers are different.
[0105] b) When k=6, if 11101110 is composed of the first 6 bits (111011) of the separator and the 2-bit number ab, that is, ab111011=11101110, since the binary numbers in the corresponding positions are different, this situation is impossible; if 11101110 is composed of the last 6 bits (101110) of the separator and the 2-bit number ab, that is, 101110ab=11101110, since the binary numbers in the corresponding positions are different, this situation is also impossible.
[0106] c) When k=5, if 11101110 is composed of the first 5 bits (11101) of the separator and the 3-bit number abc, that is, abc11101=11101110, since the binary numbers in the corresponding positions are different, this situation is impossible; if 11101110 is composed of the last 5 bits (01110) of the separator and the 3-bit number abc, that is, 01110abc=11101110, since the binary numbers in the corresponding positions are different, this situation is also impossible.
[0107] e) When k = 4, if 11101110 is composed of the first 4 bits (1110) of the separator and the 4-bit bit number abcd, i.e., abcd1110 = 11101110, then abcd = 1110. However, This contradicts the fact that the binary number abcd is a binary number in set K, therefore, this situation is impossible; if 11101110 is composed of the last 4 bits (1110) of the separator and the 4-bit bit number abcd, that is, 1110abcd = 11101110, then abcd = 1110, however... This contradicts the fact that the binary number abcd is a binary number in set K, therefore, this situation is impossible.
[0108] f) When k=3, if 11101110 is composed of the first 3 bits (111) of the separator and the 5-bit number abcde, i.e. abcde111=11101110, since the binary numbers in the corresponding positions are different, this situation is impossible; if 11101110 is composed of the last 3 bits (110) of the separator and the 5-bit number abcde, i.e. 110abcde=11101110, since the binary numbers in the corresponding positions are different, this situation is also impossible.
[0109] g) When k=2, if 11101110 is composed of the first 2 bits (11) of the separator and the 6-bit number abcdef, that is, abcdef11=11101110, since the binary numbers in the corresponding positions are different, this situation is impossible; if 11101110 is composed of the last 2 bits (10) of the separator and the 6-bit number abcdef, that is, 10abcdef=11101110, since the binary numbers in the corresponding positions are different, this situation is also impossible.
[0110] h) When k=1, if 11101110 is composed of the first bit (1) in the separator and the 7-bit number abcdefg, that is, abcdefg1=11101110, since the binary numbers in the corresponding positions are different, this situation is impossible; if 11101110 is composed of the last bit (0) in the separator and the 6-bit number abcdefg, that is, 0abcdefg=11101110, since the binary numbers in the corresponding positions are different, this situation is also impossible.
[0111] i) When k = 0, that is, 11101110 does not contain the character in the separator, that is, 11101110 is composed of bit number X. 4bit Based on the number and the offset of the highest bit from 11101110, the composition can be divided into the following four cases:
[0112] The first case: 11101110 is offset by 0 bits, such as... Figure 4a As shown, at this time, the number n = 1110, and the number... This contradicts the fact that the binary number n is a binary number in the set K, therefore, this situation is impossible.
[0113] The second case: 11101110 is offset by 1 bit, such as... Figure 4b As shown, at this time, the number n = 1101, the number... This contradicts the fact that the binary number n is a binary number in the set K, therefore, this situation is impossible.
[0114] The third case: 11101110 is offset by 2 bits, such as... Figure 4c As shown, at this time, the number n = 1011, the number... This contradicts the fact that the binary number n is a binary number in the set K, therefore, this situation is impossible.
[0115] The fourth case: 11101110 is offset by 3 bits, such as... Figure 4d As shown, at this time, the number n = 0111, the number... This contradicts the fact that the binary number n is a binary number in the set K, therefore, this situation is impossible.
[0116] As explained above, it is impossible for k to be 0, 1, 2, 3, 4, 5, 6, or 7, while when k is 8, 11101110 is definitely a separator. Furthermore, since the range of k is [0, 8], when 11101110 is detected, it must be a separator, and it cannot be caused by other situations.
[0117] It should be noted that when the separator is a different value, such as 11011101, 10111011 or 01110111, it can be proven in a similar way that the detected separator can only be a separator and cannot be caused by other situations.
[0118] See Figure 5 The diagram shown is a program block diagram of an embodiment of the data encoding device 50 of this application.
[0119] In this embodiment, the data encoding device 50 includes a series of computer program instructions stored in a memory. When these computer program instructions are executed by a processor, they can implement the data encoding functions of the various embodiments of this application. In some embodiments, based on the specific operations implemented by each part of the computer program instructions, the data encoding device 50 can be divided into one or more modules. Specifically, the modules that can be divided are as follows:
[0120] The acquisition module 51 is used to acquire data to be encoded, the data to be encoded including number information, the number information including at least one number represented by a decimal number;
[0121] The encoding module 52 is used to convert each decimal number in the numbering information into a corresponding initial binary number according to a preset encoding mapping table to obtain an initial binary number group. The encoding mapping table records the mapping relationship between each decimal number 0 to 9 and the corresponding initial binary number.
[0122] The splicing module 53 is used to splice a preset separator to the left of the highest bit or the right of the lowest bit of the initial binary number group to generate target encoded data. The separator includes M groups of identical binary identifier numbers. The initial binary number and the binary identifier number are both composed of N binary numbers. The binary identifier number has (N-1) binary numbers 0 or 1, where N is an integer greater than or equal to 4 and M is an integer greater than or equal to 2.
[0123] Wherein, when the binary identifier number has (N-1) binary 0s, the initial binary number does not have (N-1) binary 0s;
[0124] When the binary identifier number has (N-1) binary 1s, the initial binary number does not have (N-1) binary 1s.
[0125] In one exemplary embodiment, the separator consists of two identical sets of binary identifier numbers, both of which consist of four binary digits.
[0126] In an exemplary embodiment, when the separator is 11101110, 11011101, 10111011, or 01110111, the initial binary number corresponding to the decimal digits 0-9 is any 10 binary numbers in the first set, which includes the following 12 binary numbers:
[0127] 0000, 0001, 0010, 0011, 0100, 0101, 0110, 1000, 1001, 1010, 1100, 1111.
[0128] In one exemplary embodiment, when the separator is 00010001, 00100010, 01000100, or 10001000, the initial binary number corresponding to the decimal digits 0-9 is any 10 binary numbers from the second set, which includes the following 12 binary numbers:
[0129] 0000, 0011, 0101, 0110, 0111, 1001, 1010, 1011, 1100, 1101, 1110, 1111.
[0130] In one exemplary embodiment, the separator is 11101110, and the initial binary numbers corresponding to the decimal numbers 0 to 9 are as follows: 0000, 0001, 0010, 0011, 0100, 0101, 0110, 1000, 1001, 1010.
[0131] See Figure 6 The diagram shown is a program block diagram of an embodiment of the data decoding device 60 of this application.
[0132] In this embodiment, the data decoding device 60 includes a series of computer program instructions stored in a memory. When these computer program instructions are executed by a processor, they can implement the data decoding functions of the various embodiments of this application. In some embodiments, based on the specific operations implemented by each part of the computer program instructions, the data decoding device 60 can be divided into one or more modules. Specifically, the modules that can be divided are as follows:
[0133] The acquisition module 60 is used to acquire the data to be decoded, which is obtained by encoding multiple data to be encoded by the data encoding method described above.
[0134] Detection module 61 is used to detect the separator identifier from the data to be decoded;
[0135] The decoding module 62 is used to decode the data before the separator and / or the data after the separator according to a preset encoding mapping table to obtain the decoding result. The encoding mapping table records the mapping relationship between decimal numbers 0 to 9 and their corresponding initial binary numbers.
[0136] Figure 7 This illustration schematically depicts a hardware architecture diagram of a computer device 7 suitable for implementing data encoding or data decoding methods according to an embodiment of this application. In this embodiment, the computer device 7 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Figure 7 As shown, the computer device 7 includes, but is not limited to, at least: a memory 120, a processor 121, and a network interface 122 that can communicate with each other via a system bus. Wherein:
[0137] The memory 120 includes at least one type of computer-readable storage medium, which can be volatile or non-volatile. Specifically, the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 120 may be an internal storage module of the computer device 7, such as the hard disk or memory of the computer device 7. In other embodiments, the memory 120 may also be an external storage device of the computer device 7, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on the computer device 7. Of course, the memory 120 may also include both the internal storage module and the external storage device of the computer device 7. In this embodiment, the memory 120 is typically used to store the operating system and various application software installed on the computer device 7, such as program code for data encoding or data decoding methods. Furthermore, the memory 120 can also be used to temporarily store various types of data that have already been output or will be output.
[0138] In some embodiments, processor 121 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data encoding or decoding chip. Processor 121 is typically used to control the overall operation of computer device 7, such as performing control and processing related to data interaction or communication with computer device 7. In this embodiment, processor 121 is used to run program code stored in memory 120 or process data.
[0139] Network interface 122 may include a wireless network interface or a wired network interface, which is typically used to establish a communication link between computer device 7 and other computer devices. For example, network interface 122 is used to connect computer device 7 to an external terminal via a network, establishing a data transmission channel and communication link between computer device 7 and the external terminal. The network may be an intranet, the Internet, Global System for Mobile Communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, or other wireless or wired networks.
[0140] It should be pointed out that, Figure 7 Only computer devices with components 120 to 122 are shown; however, it should be understood that it is not required to implement all of the shown components, and more or fewer components may be implemented instead.
[0141] In this embodiment, the data encoding or data decoding method stored in the memory 120 can be divided into one or more program modules and executed by one or more processors (processor 121 in this embodiment) to complete this application.
[0142] This application provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the steps of the data encoding or data decoding method in the embodiment.
[0143] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computer device, such as the hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. Of course, the computer-readable storage medium can also include both internal storage units and external storage devices of the computer device. In this embodiment, the computer-readable storage medium is typically used to store the operating system and various application software installed on the computer device, such as the program code of the data encoding or data decoding methods in the embodiments. Furthermore, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or will be output.
[0144] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across at least two network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of this application. Those skilled in the art can understand and implement this without any creative effort.
[0145] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or of course, using hardware. Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0146] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A data encoding method, characterized in that, The method includes: Obtain data to be encoded, the data to be encoded including numbering information, the numbering information including at least one number represented by a decimal number; According to the preset encoding mapping table, each decimal number in the numbering information is converted into the corresponding initial binary number in turn to obtain the initial binary number group. The encoding mapping table records the mapping relationship between each decimal number 0 to 9 and the corresponding initial binary number. A preset separator is concatenated to the left of the highest bit or the right of the lowest bit of the initial binary number group to generate target encoded data. The separator includes M groups of identical binary identifier numbers. Both the initial binary number and the binary identifier number are composed of N binary digits. The binary identifier number has (N-1) binary numbers 0 or 1, where N is an integer greater than or equal to 4 and M is an integer greater than or equal to 2. Wherein, when the binary identifier number has (N-1) binary 0s, the initial binary number does not have (N-1) binary 0s; When the binary identifier number has (N-1) binary 1s, the initial binary number does not have (N-1) binary 1s.
2. The data encoding method according to claim 1, characterized in that, The separator consists of two identical sets of binary identifier numbers, and both the initial binary number and the binary identifier number consist of four binary digits.
3. The data encoding method according to claim 2, characterized in that, When the separator is 11101110, 11011101, 10111011, or 01110111, the initial binary number corresponding to the decimal digits 0-9 is any 10 binary numbers in the first set, which includes the following 12 binary numbers: 0000、0001、0010、0011、0100、0101、0110、1000、1001、1010、1100、1111。 4. The data encoding method according to claim 2, characterized in that, When the separator is 00010001, 00100010, 01000100, or 10001000, the initial binary number corresponding to the decimal digits 0-9 is any 10 binary numbers in the second set, which includes the following 12 binary numbers: 0000、0011、0101、0110、0111、1001、1010、1011、1100、1101、1110、1111。 5. The data encoding method according to claim 2, characterized in that, The separator is 11101110, and the initial binary numbers corresponding to the decimal numbers 0 to 9 are as follows: 0000, 0001, 0010, 0011, 0100, 0101, 0110, 1000, 1001, 1010.
6. A data decoding method, characterized in that, The method includes: Obtain the data to be decoded, wherein the data to be decoded is obtained by encoding multiple data to be encoded using the data encoding method according to any one of claims 1 to 5; Detect the separator from the data to be decoded; The data before and / or after the separator is decoded according to a preset encoding mapping table to obtain the decoding result. The encoding mapping table records the mapping relationship between decimal numbers 0 to 9 and their corresponding initial binary numbers.
7. A data encoding device, characterized in that, The data encoding device includes: An acquisition module is used to acquire data to be encoded, the data to be encoded including numbering information, the numbering information including at least one number represented by a decimal number; The encoding module is used to convert each decimal number in the numbering information into a corresponding initial binary number according to a preset encoding mapping table, so as to obtain an initial binary number group. The encoding mapping table records the mapping relationship between each decimal number 0 to 9 and the corresponding initial binary number. The splicing module is used to splice a preset separator to the left of the highest bit or the right of the lowest bit of the initial binary number group to generate target encoded data. The separator includes M groups of identical binary identifier numbers. Both the initial binary number and the binary identifier number are composed of N binary digits. The binary identifier number has (N-1) binary numbers 0 or 1, where N is an integer greater than or equal to 4 and M is an integer greater than or equal to 2. Wherein, when the binary identifier number has (N-1) binary 0s, the initial binary number does not have (N-1) binary 0s; When the binary identifier number has (N-1) binary 1s, the initial binary number does not have (N-1) binary 1s.
8. A data decoding device, characterized in that, The data decoding device includes: An acquisition module is used to acquire data to be decoded, wherein the data to be decoded is obtained by encoding multiple data to be encoded using the data encoding method according to any one of claims 1 to 5; The detection module is used to detect the separator identifier from the data to be decoded; The decoding module is used to decode the data before the separator and the data after the separator according to a preset encoding mapping table to obtain the decoding result. The encoding mapping table records the mapping relationship between decimal numbers 0 to 9 and their corresponding initial binary numbers.
9. A computer device, characterized in that, The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.