Character-oriented data encoding method and system

By converting ASCII codes into six-bit encoding and merging them into eight-bit encoding, the problem of data redundancy in narrowband data transmission is solved, and data traffic is saved.

CN118433258BActive Publication Date: 2025-11-07昊野科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311162537.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-08
Publication Date
2025-11-07
Estimated Expiration
2043-09-08

AI Technical Summary

Technical Problem

In narrowband data transmission, existing encoding techniques cannot effectively reduce data redundancy, resulting in wasted data traffic. In particular, when transmitting ASCII characters, the eight-bit encoding format fails to effectively save data traffic.

Method used

Using a six-bit encoding technique, the ASCII code is subtracted by 20H. The byte value is then used to determine if it is less than or equal to 3FH. If it is, the two highest bits are removed to form a six-bit code. Otherwise, an identifier is set to transmit in an eight-bit code, and the six-bit code is merged into three eight-bit codes. If the result is less than three bytes, zeros are added before transmission.

Benefits of technology

It realizes the conversion of eight-bit ASCII code to six-bit encoding, reduces data stream redundancy, improves the efficiency of narrowband data transmission, and saves data traffic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118433258B_ABST
    Figure CN118433258B_ABST
Patent Text Reader

Abstract

The application discloses a character-oriented data encoding method and system, and particularly relates to data transmission of narrowband internet of things. The method comprises the following steps: subtracting 20H from each byte in an ASCII code string to be sent; judging whether the byte after the subtraction is less than or equal to 3FH, if yes, removing the high two bits to form six-bit encoding; if no, setting an identifier in a transmission protocol and transmitting in eight-bit encoding; and transmitting after merging four six-bit encodings into three eight-bit encodings. The method solves the waste of one character and one byte transmission in the existing data transmission process, and helps to reduce the data transmission length and the use of data flow.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data coding, in particular to a character-oriented data coding method and system. BACKGROUND

[0002] In the application of Internet of Things and IOT, narrowband transmission is mainly used, the amount of transmitted data is relatively small, and the characters and contents transmitted are relatively single. A large number of JSON strings encoded by ASCII characters are used for transmission. When eight-bit ASCII code is used for transmission, numbers, capital letters and symbols are mostly used, and there are no non-displayable characters, and Chinese characters are almost not used. Most data transmission modules have binary transmission capability, and most communication protocols are artificially specified, which provides conditions for reducing data redundancy. Therefore, for the transmission of one character per byte, the redundant binary bits are too many, resulting in waste of data flow.

[0003] In the existing data compression technology, most of them are concentrated in the field of wideband data transmission. For example, in the scheme with the application number 201010298614.4 and the name of compression encoding method, decoding and decompression method, device and communication system, the voice, audio, image and video signals are compressed and encoded for transmission in the wideband transmission process. The BASE 64 encoding commonly used in transmission requires converting every three 8-bit bytes into four 6-bit bytes, and then adding two high bits 0 to the 6-bit to form four 8-bit bytes. That is to say, the length of the converted string will be theoretically 1 / 3 longer than the original. Therefore, this form cannot effectively save data flow. Therefore, how to use simple encoding form to simplify the redundant part of data stream and realize simple and efficient transmission of data is a problem to be solved in the field of narrowband data transmission. BASE64 encoding is commonly used for web transmission, and the HTTP protocol stipulates that binary information cannot be transmitted. SUMMARY

[0004] Therefore, the purpose of the present application is to provide a character-oriented data coding method, which uses six-bit coding transmission technology to help reduce data transmission length and reduce data flow usage.

[0005] In ASCII coding, 0-31 are non-displayable characters and are not used for data transmission. In this paper, the ASCII coding data is reduced by 20H, and finally six-bit coding transmission is realized.

[0006] The present application provides a character-oriented data coding method, comprising the following steps:

[0007] Each byte of the ASCII code string to be sent is reduced by 20H;

[0008] If the byte to be transmitted after subtracting 20H is less than or equal to 3FH, the upper two bits are removed to form six-bit encoding; if greater than 3FH, an identifier is set in the transmission protocol for transmission in eight-bit encoding;

[0009] The formed six-bit encoding is transmitted after being combined into three eight-bit encodings according to four six-bit encodings; and if less than three bytes, 0 is used to supplement to three bytes at the end.

[0010] Further preferably, when greater than 3FH, the identifier includes the following forms when an identifier is set in the transmission protocol for transmission in eight-bit encoding:

[0011] Form 1: 3FH encoding is used to represent the subsequent content as eight-bit encoding, and a whole byte 0 is used as an end marker;

[0012] Form 2: 3FH encoding is used to represent the subsequent content as eight-bit encoding, and the transmission is performed in the order of 3FH encoding, byte length identifier, and eight-bit encoding characters.

[0013] Further preferably, the character length identifier uses ASCII code of byte data length or binary data of a specified length to represent the byte length of the subsequent eight-bit encoding characters.

[0014] Further preferably, when decoding, the following process is included:

[0015] The continuous six-bit encoding in every three bytes of the received data is divided into four groups, which are expanded into four bytes, and the upper two bits of each byte are supplemented with 0; then each byte is added by 20H, and the tail space is eliminated.

[0016] The application also provides a character-oriented data encoding system, which includes a compression module, a judgment module, and an encoding module.

[0017] The compression module is used to subtract 20H from each byte in the ASCII code string to be transmitted.

[0018] The judgment module judges whether the byte to be transmitted after subtracting 20H is less than or equal to 3FH, if yes, the upper two bits are removed to form six-bit encoding; if greater than 3FH, an identifier is set in the transmission protocol for transmission in eight-bit encoding.

[0019] The encoding module transmits the formed six-bit encoding after combining four six-bit encodings into three eight-bit encodings; and if less than three bytes, 0 is used to supplement to three bytes at the end.

[0020] Further preferably, in the judgment module, when greater than 3FH, the identifier includes the following forms when an identifier is set in the transmission protocol for transmission in eight-bit encoding:

[0021] Form 1, the subsequent content is expressed as octal code by transmitting 3FH code, and the end mark is a whole byte 0;

[0022] Form 2, the subsequent content is expressed as octal code by transmitting 3FH code, and the transmission is performed in the order of 3FH code, byte length identifier, and octal code character.

[0023] Further preferably, the character length identifier uses the ASCII code of the byte data length or the binary data of the specified length to express the byte length of the subsequent octal code character

[0024] Further preferably, when decoding, the following process is included:

[0025] In the received data, every three bytes are expanded into four bytes, the high two bits of each byte are filled with 0, each byte is added by 20H, and the tail space is eliminated.

[0026] The character-oriented data encoding method disclosed in the present application has at least the following advantages compared with the prior art: the conversion of 8-bit ASCII code into six-bit code is realized, four six-bit codes are combined into three octal codes for transmission; the redundant part of the data stream is reduced, the simple and efficient transmission of data is realized, and the waste of flow in narrowband data transmission is saved. BRIEF DESCRIPTION OF DRAWINGS

[0027] Figure 1 It is a flowchart of the character-oriented data encoding method of the present application.

[0028] Figure 2 It is a structural schematic diagram of the character-oriented data encoding system of the present application. DETAILED DESCRIPTION

[0029] The present application will be further described in detail through the accompanying drawings and specific embodiments.

[0030] As shown in the drawings, Figure 1 the character-oriented data encoding method provided by an embodiment of the present application comprises the following steps:

[0031] S1, subtracting 20H (H represents hexadecimal, the same below, and converting to decimal means subtracting 32 from each byte) from each byte in the ASCII code character string to be sent;

[0032] S2, judging whether the byte to be sent after subtracting 20H is less than or equal to 3FH, if yes, removing the high two bits to form six-bit code; if greater than 3FH, setting an identifier in the transmission protocol for transmission in octal code;

[0033] If greater than 3FH, an identifier is set in the transmission protocol, and the identifier includes the following forms when the subsequent content is transmitted in octet coding:

[0034] Form 1, indicating that the subsequent content is octet coding by transmitting 3FH coding, and taking the whole byte 0 as an end mark;

[0035] Form 2, indicating that the subsequent content is octet coding by transmitting 3FH coding, and transmitting in the order of 3FH coding, byte length identification, and octet coding characters.

[0036] The character length identification indicates the byte length of the subsequent octet coding characters by using the ASCII code of the byte data length or the binary data of a specified length.

[0037] S3, merging the formed six-bit coding into three octet codings in the order of four six-bit codings, and transmitting; if less than three bytes, supplementing with 0 at the end.

[0038] When decoding, the following processes are included:

[0039] Unfolding every three bytes in the received data into four bytes, supplementing 0 to the high two bits of each byte, adding 20H to each byte, and eliminating the tail space and the originally supplemented part.

[0040] As shown in Figure 2 The application also provides a character-oriented data coding system, which includes a compression module, a judgment module, and a coding module.

[0041] The compression module is used for subtracting 20H from each byte in the ASCII code character string to be sent.

[0042] The judgment module judges whether the byte to be sent after subtracting 20H is less than or equal to 3FH, if yes, removing the high two bits to form six-bit coding; if greater than 3FH, setting an identifier in the transmission protocol to transmit in octet coding; preferably, when the subsequent content is transmitted in octet coding, the identifier includes the following forms:

[0043] Form 1, indicating that the subsequent content is octet coding by transmitting 3FH coding, and taking the whole byte 0 as an end mark;

[0044] Form 2, indicating that the subsequent content is octet coding by transmitting 3FH coding, and transmitting in the order of 3FH coding, byte length identification, and octet coding characters.

[0045] Further, the character length identification indicates the byte length of the subsequent octet coding characters by using the ASCII code of the byte data length or the binary data of a specified length.

[0046] The encoding module combines the formed six-bit code into three eight-bit codes and transmits the codes; if there are less than three bytes, the codes are supplemented with 0 at the end.

[0047] The decoding module includes the following processes during decoding:

[0048] The received data is expanded into four bytes from every three bytes, the high two bits of each byte are supplemented with 0, each byte is added with 20H, and the tail space is eliminated to remove the originally supplemented part.

[0049] Obviously, the above embodiments are only examples for clearly illustrating the present application, and are not intended to limit the present application. Based on the above description, other different forms of changes or variations can be made by those skilled in the art. Here, all the embodiments are not required to be exhausted, and the obvious changes or variations derived therefrom are still within the protection scope of the present application.

Claims

1. A character-oriented data encoding method, characterized by, It comprises the following steps: Subtracting 20H from each byte in the ASCII code string to be sent; If the byte after subtracting 20H is less than or equal to 3FH, the upper two bits are removed to form six-bit encoding; If it is greater than 3FH, an identifier is set in the transmission protocol for transmission in eight-bit encoding; The formed six-bit encoding is transmitted after being combined into three eight-bit encodings according to four six-bit encodings; if there are less than three bytes, 0 is added at the end to three bytes; When it is greater than 3FH, the identifier includes the following forms when an identifier is set in the transmission protocol for transmission in eight-bit encoding: Form 1: 3FH encoding is transmitted to indicate that the subsequent content is eight-bit encoding, and a whole byte of 0 is used as an end marker; Form 2: 3FH encoding is transmitted to indicate that the subsequent content is eight-bit encoding, and the transmission is performed in the order of 3FH encoding, byte length identifier, and eight-bit encoding character.

2. The character-oriented data encoding method of claim 1, wherein, The byte length identifier uses the ASCII code of the byte data length or the binary data of a specified length to represent the byte length of the subsequent eight-bit encoding character.

3. The character-oriented data encoding method of claim 1, wherein, When decoding, the following process is included: The continuous six-bit encoding in each three bytes of the received data is divided into four groups, which are expanded into four bytes, and the upper two bits of each byte are supplemented with 0; then each byte is added with 20H, and the tail space is eliminated.

4. A character-oriented data encoding system characterized by comprising: It comprises a compression module, a judgment module, and an encoding module; The compression module is used to subtract 20H from each byte in the ASCII code string to be sent; The judgment module judges whether the byte to be sent after subtracting 20H is less than or equal to 3FH, if so, the upper two bits are removed to form six-bit encoding; If it is greater than 3FH, an identifier is set in the transmission protocol for transmission in eight-bit encoding; The encoding module transmits the formed six-bit encoding after combining four six-bit encodings into three eight-bit encodings; if there are less than three bytes, 0 is added at the end to three bytes; In the judgment module, when it is greater than 3FH, the identifier includes the following forms when an identifier is set in the transmission protocol for transmission in eight-bit encoding: Form 1: 3FH encoding is transmitted to indicate that the subsequent content is eight-bit encoding, and a whole byte of 0 is used as an end marker; Form 2: 3FH encoding is transmitted to indicate that the subsequent content is eight-bit encoding, and the transmission is performed in the order of 3FH encoding, byte length identifier, and eight-bit encoding character.

5. The character-oriented data encoding system of claim 4, wherein, The byte length identifier uses the ASCII code of the byte data length or the binary data of a specified length to represent the byte length of the subsequent eight-bit encoding character.

6. The character-oriented data encoding system of claim 5, wherein, When decoding, the following process is included: The continuous six-bit encoding in each three bytes of the received data is divided into four groups, which are expanded into four bytes, and the upper two bits of each byte are supplemented with 0; then each byte is added with 20H, and the tail space is eliminated.

Citation Information

Patent Citations

  • Compression coding method, decoding decompression method, device and communication system

    CN101945286B

  • Character coding and decoding method and device

    CN105391514A