Serial port screen coding format conversion method and device and electronic equipment
By constructing a target format mapping file, the serial port screen encoding format conversion is realized, which solves the problems of limited use and garbled characters caused by a single encoding format in the existing technology, and improves the application efficiency and convenience of the serial port screen.
Patent Information
- Application Number
- CN202411478823.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, the serial port screen can only set one encoding format, and cannot convert the format, resulting in limited use and prone to garbled code problems, especially when switching between multiple languages.
By constructing a target format mapping file, including the mapping relationship between different encoding formats, the conversion of encoding formats is achieved. Specific steps include obtaining the path address data of the mapping file, traversing the characters in the file, obtaining the encoding value in the first format, and converting it to the encoding value in the second format according to the mapping relationship, and finally obtaining the target encoding string.
It achieves flexible conversion of the serial screen encoding format, improves the encoding format conversion efficiency, avoids garbled characters, and provides convenience for the multi-language application of the serial screen.
Smart Images

Figure CN119336691A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, electronic device and storage medium for converting serial port screen coding formats. Background Art
[0002] In the application process of the serial port screen in the prior art, a text control can usually only set one encoding format, and the format conversion cannot be performed, which greatly limits the use of the serial port screen and even leads to various situations in the use of the serial port screen. For example, when using the serial port command to update the string, and typing the updated string on the keyboard, the string must be processed according to the pre-set encoding format. If it is not processed according to the pre-set encoding format, garbled characters will appear; or when switching between multiple languages, because different languages require completely different encoding formats, if only a single encoding format is used, garbled characters will also appear. The limitation of the encoding format has caused many inconveniences in the use of the serial port screen. Summary of the invention
[0003] The purpose of the present application is to provide a method, device, electronic device and storage medium for converting the encoding format of a serial port screen, which can flexibly convert the encoding format of the serial port screen, improve the efficiency of the encoding format conversion, make the encoding format not restricted, and be less prone to garbled characters, thereby providing convenience for the application of the serial port screen.
[0004] In a first aspect, an embodiment of the present application provides a method for converting a serial port screen encoding format, the method comprising:
[0005] Constructing a target format mapping file, wherein the target format mapping file includes a mapping relationship between the first format and the second format;
[0006] Obtaining the path address data of the target format mapping file according to the first function;
[0007] Traversing the characters in the target format mapping file according to the path address data to obtain a code value in a first format;
[0008] Obtaining, according to the mapping relationship, a code value in a second format corresponding to the code value in the first format;
[0009] A target encoded character string is obtained according to the encoded value in the second format.
[0010] In the above implementation process, a target format mapping file is constructed, and the first format and the second format of the encoding are converted according to the mapping relationship. The serial port screen encoding format can be flexibly converted to improve the efficiency of encoding format conversion, so that the encoding format will not be restricted and garbled characters will not easily appear, which provides convenience for the application of the serial port screen.
[0011] Furthermore, the step of traversing the characters in the target format mapping file according to the path address data to obtain the encoding value of the first format includes:
[0012] Determining whether the path address data meets a first threshold;
[0013] If yes, no encoding format conversion is performed;
[0014] If not, the target format mapping file is opened and traversed according to the second function to obtain the encoding value of the first format.
[0015] In the above implementation process, when the path address data does not meet the first threshold, the target format mapping file is traversed to quickly filter the data that needs to be format converted or can be format converted, thereby improving the efficiency of format conversion.
[0016] Further, the step of opening the target format mapping file according to the second function to traverse and obtain the encoding value of the first format includes:
[0017] Open the target format mapping file according to the second function, and read the character string in the target format mapping file;
[0018] Traverse each character in the string to obtain a length variable of each character;
[0019] The encoding value of the first format is obtained according to the length variable of each character.
[0020] In the above implementation process, the characters in the string that meets the requirements are traversed and the length variable of each character is obtained, so that the encoding value of the first format can be accurately obtained, which facilitates the conversion of the first format.
[0021] Furthermore, the step of obtaining the encoding value of the first format according to the length variable of each character includes:
[0022] Divide each character according to the length variable to obtain multiple groups of characters, each group of characters corresponding to a length variable;
[0023] Get the encoding value of the first format corresponding to the length variable of each group of characters.
[0024] In the above implementation process, each character is divided according to the length variable to obtain multiple groups of characters, which can accurately identify and recognize the characters and determine the attributes of the characters, thereby more accurately obtaining the encoding value of the first format corresponding to each group of characters.
[0025] Further, the step of obtaining, according to the mapping relationship, a code value in the second format corresponding to the code value in the first format includes:
[0026] Determine whether the encoding value of the first format is greater than a second threshold;
[0027] If so, searching, according to the mapping relationship, for a code value in the second format corresponding to the code value in the first format;
[0028] If not, the encoded value in the first format is not converted.
[0029] In the above implementation process, the code value in the first format is judged, so as to find the code value in the second format corresponding to the code value in the first format, so as to accurately screen out the code value to be converted and reduce data redundancy.
[0030] Furthermore, the step of obtaining a target encoded string according to the encoded value in the second format includes:
[0031] Moving the file pointer corresponding to the encoding value in the second format to a target position according to a third function;
[0032] Read the byte data at the target position according to a fourth function;
[0033] The byte data is converted into the target encoded character string according to a fifth function.
[0034] In the above implementation process, the file pointer corresponding to the encoding value of the second format is moved according to the third function, so as to read the byte data at the target position after the move, realize the conversion of the byte data, improve the accuracy and efficiency of the conversion, and reduce errors.
[0035] Furthermore, after the step of obtaining the target encoded string according to the encoded value in the second format, the method further includes:
[0036] The target encoding character string is added to the path address data.
[0037] In the above implementation process, adding the target encoding string to the value path address data can provide traversal for the use of the serial port screen and reduce the garbled code phenomenon.
[0038] In a second aspect, an embodiment of the present application further provides a device for converting a serial port screen encoding format, the device comprising:
[0039] A construction module, configured to construct a target format mapping file, wherein the target format mapping file includes a mapping relationship between a first format and a second format;
[0040] A data acquisition module, used to obtain the path address data of the target format mapping file according to the first function; further used to traverse the characters in the target format mapping file according to the path address data to obtain the encoding value of the first format; further used to obtain the encoding value of the second format corresponding to the encoding value of the first format according to the mapping relationship;
[0041] A conversion module is used to obtain a target encoding character string according to the encoding value in the second format.
[0042] In the above implementation process, a target format mapping file is constructed, and the first format and the second format of the encoding are converted according to the mapping relationship. The serial port screen encoding format can be flexibly converted to improve the efficiency of encoding format conversion, so that the encoding format will not be restricted and garbled characters will not easily appear, which provides convenience for the application of the serial port screen.
[0043] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of the first aspects when executing the computer program.
[0044] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which instructions are stored. When the instructions are executed on a computer, the computer executes the method as described in any one of the first aspects.
[0045] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on a computer, enables the computer to execute the method as described in any one of the first aspects.
[0046] Other features and advantages of the present disclosure will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present disclosure.
[0047] And it can be implemented according to the contents of the specification. The following is a detailed description of the preferred embodiments of the present application with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the range values. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.
[0049] Figure 1A flowchart of a method for converting serial port screen encoding format provided in an embodiment of the present application;
[0050] Figure 2 A schematic diagram of the structure of the serial port screen encoding format conversion device provided in an embodiment of the present application;
[0051] Figure 3 A schematic diagram of the structural composition of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0053] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0054] The specific implementation methods of the present application are further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present application, but are not used to limit the scope of the present application.
[0055] Embodiment 1
[0056] Figure 1 : is a flow chart of a method for converting a serial port screen encoding format provided in an embodiment of the present application, such as Figure 1 As shown, the method includes:
[0057] S1, constructing a target format mapping file, where the target format mapping file includes a mapping relationship between a first format and a second format;
[0058] S2, obtaining path address data of the target format mapping file according to the first function;
[0059] S3, traversing the characters in the target format mapping file according to the path address data to obtain the encoding value of the first format;
[0060] S4, obtaining a code value in a second format corresponding to the code value in the first format according to the mapping relationship;
[0061] S5, obtaining a target encoding character string according to the encoding value in the second format.
[0062] In the above implementation process, a target format mapping file is constructed, and the first format and the second format of the encoding are converted according to the mapping relationship. The serial port screen encoding format can be flexibly converted to improve the efficiency of encoding format conversion, so that the encoding format will not be restricted and garbled characters will not easily appear, which provides convenience for the application of the serial port screen.
[0063] In S1, the path of the GBK mapping file (target format mapping file) is defined. Since the encoding format of the embodiment of the present application is converted from UTF-8 encoding to GBK encoding, the target format mapping file also contains a mapping relationship from UTF-8 encoding to GBK encoding.
[0064] The first format in the embodiment of the present application corresponds to the UTF-8 encoding format, and the second format corresponds to the GBK encoding format.
[0065] In S2, the content (path address data) at the corresponding address of the interface is obtained according to the get_string function (first function).
[0066] Furthermore, S3 includes:
[0067] Determining whether the path address data meets a first threshold;
[0068] If yes, no encoding format conversion is performed;
[0069] If not, the target format mapping file is opened and traversed according to the second function to obtain the encoding value of the first format.
[0070] In the above implementation process, when the path address data does not meet the first threshold, the target format mapping file is traversed to quickly filter the data that needs to be format converted or can be format converted, thereby improving the efficiency of format conversion.
[0071] If the path address data is nil (the first threshold), exit directly without converting the encoding format. If the path address data is not nil, enter the utf8_to_str_gbk function for conversion.
[0072] The embodiment of the present application adopts the file_open(path, 1) function (the second function) and opens the target format mapping file in a read-only manner.
[0073] Further, the step of opening the target format mapping file according to the second function and traversing it to obtain the encoding value of the first format includes:
[0074] Open the target format mapping file according to the second function, and read the character string in the target format mapping file;
[0075] Traverse each character in the string and get the length variable of each character;
[0076] Obtains the first format encoding value based on the length variable of each character.
[0077] In the above implementation process, the characters in the string that meets the requirements are traversed and the length variable of each character is obtained, so that the encoding value of the first format can be accurately obtained, which facilitates the conversion of the first format.
[0078] Each character is processed in a loop. The embodiment of the present application uses a while loop to traverse each character until all characters are processed, and uses string.byte to obtain the length variable in the UTF-8 encoding format.
[0079] Furthermore, the step of obtaining the encoding value of the first format according to the length variable of each character includes:
[0080] Divide each character according to the length variable to obtain multiple groups of characters, each group of characters corresponds to a length variable;
[0081] Get the encoding value of the first format corresponding to the length variable of each group of characters.
[0082] In the above implementation process, each character is divided according to the length variable to obtain multiple groups of characters, which can accurately identify and recognize the characters and determine the attributes of the characters, thereby more accurately obtaining the encoding value of the first format corresponding to each group of characters.
[0083] Exemplarily, UTF-8 characters of different lengths are classified and processed, and the UTF-8 encoding value corresponding to each length variable is calculated according to 1-byte, 2-byte, 3-byte and 4-byte UTF-8 characters respectively.
[0084] Furthermore, S4 includes:
[0085] Determine whether the encoding value of the first format is greater than a second threshold;
[0086] If so, searching for a code value in the second format corresponding to the code value in the first format according to the mapping relationship;
[0087] If not, no conversion is performed on the encoded value in the first format.
[0088] In the above implementation process, the code value in the first format is judged, so as to find the code value in the second format corresponding to the code value in the first format, so as to accurately screen out the code value to be converted and reduce data redundancy.
[0089] If the encoding value (strval) of the first format is greater than 0x4E01 (the second threshold), that is, the character is determined to be a Chinese character, then the corresponding GBK encoding value (the encoding value of the second format) is searched from the target format mapping file.
[0090] Furthermore, S5 includes:
[0091] Moving the file pointer corresponding to the encoded value in the second format to the target position according to the third function;
[0092] Read the byte data at the target location according to the fourth function;
[0093] Convert the byte data into a target encoding string according to the fifth function.
[0094] In the above implementation process, the file pointer corresponding to the encoding value of the second format is moved according to the third function, so as to read the byte data at the target position after the move, realize the conversion of the byte data, improve the accuracy and efficiency of the conversion, and reduce errors.
[0095] Optionally, the third function of the embodiment of the present application is a file_seek function, the fourth function is a file_read function, and the fifth function is a string.pack("H",strval) function. The embodiment of the present application moves the file pointer to the target position according to the file_seek function, and uses the file_read function to read the two bytes of data at the target position. The string.pack("H",strval) function is used to convert the byte data into a GBK encoded string.
[0096] Furthermore, after the step of obtaining the target encoded string according to the encoded value in the second format, the method further includes:
[0097] Add the target encoding string to the path address data.
[0098] In the above implementation process, adding the target encoding string to the value path address data can provide traversal for the use of the serial port screen and reduce the garbled code phenomenon.
[0099] Optionally, the embodiment of the present application uses the file_close function to close the file, returns the converted GBK encoded string, and displays the returned new string on the corresponding address of the interface (path address data), thereby converting the UTF-8 string into a GBK encoded string. The embodiment of the present application can also be applied to conversions of other formats.
[0100] Embodiment 2
[0101] In order to execute the method corresponding to the above embodiment 1 to achieve the corresponding functions and technical effects, a serial port screen encoding format conversion device is provided below, such as Figure 2 As shown, the device comprises:
[0102] Construction module 1, used to construct a target format mapping file, wherein the target format mapping file includes a mapping relationship between a first format and a second format;
[0103] Data acquisition module 2, used for obtaining path address data of the target format mapping file according to the first function; also used for traversing the characters in the target format mapping file according to the path address data to obtain the encoding value of the first format; and also used for obtaining the encoding value of the second format corresponding to the encoding value of the first format according to the mapping relationship;
[0104] The conversion module 3 is used to obtain a target encoding character string according to the encoding value in the second format.
[0105] In the above implementation process, a target format mapping file is constructed, and the first format and the second format of the encoding are converted according to the mapping relationship. The serial port screen encoding format can be flexibly converted to improve the efficiency of encoding format conversion, so that the encoding format will not be restricted and garbled characters will not easily appear, which provides convenience for the application of the serial port screen.
[0106] Furthermore, the data acquisition module 2 is also used for:
[0107] Determining whether the path address data meets a first threshold;
[0108] If yes, no encoding format conversion is performed;
[0109] If not, the target format mapping file is opened and traversed according to the second function to obtain the encoding value of the first format.
[0110] In the above implementation process, when the path address data does not meet the first threshold, the target format mapping file is traversed to quickly filter the data that needs to be format converted or can be format converted, thereby improving the efficiency of format conversion.
[0111] Furthermore, the data acquisition module 2 is also used for:
[0112] Open the target format mapping file according to the second function, and read the character string in the target format mapping file;
[0113] Traverse each character in the string and get the length variable of each character;
[0114] Obtains the first format encoding value based on the length variable of each character.
[0115] In the above implementation process, the characters in the string that meets the requirements are traversed and the length variable of each character is obtained, so that the encoding value of the first format can be accurately obtained, which facilitates the conversion of the first format.
[0116] Furthermore, the data acquisition module 2 is also used for:
[0117] Divide each character according to the length variable to obtain multiple groups of characters, each group of characters corresponds to a length variable;
[0118] Get the encoding value of the first format corresponding to the length variable of each group of characters.
[0119] In the above implementation process, each character is divided according to the length variable to obtain multiple groups of characters, which can accurately identify and recognize the characters and determine the attributes of the characters, thereby more accurately obtaining the encoding value of the first format corresponding to each group of characters.
[0120] Furthermore, the data acquisition module 2 is also used for:
[0121] Determine whether the encoding value of the first format is greater than a second threshold;
[0122] If so, searching for a code value in the second format corresponding to the code value in the first format according to the mapping relationship;
[0123] If not, no conversion is performed on the encoded value in the first format.
[0124] In the above implementation process, the code value in the first format is judged, so as to find the code value in the second format corresponding to the code value in the first format, so as to accurately screen out the code value to be converted and reduce data redundancy.
[0125] Furthermore, the conversion module 3 is also used for:
[0126] Moving the file pointer corresponding to the encoded value in the second format to the target position according to the third function;
[0127] Read the byte data at the target location according to the fourth function;
[0128] Convert the byte data into a target encoding string according to the fifth function.
[0129] In the above implementation process, the file pointer corresponding to the encoding value of the second format is moved according to the third function, so as to read the byte data at the target position after the move, realize the conversion of the byte data, improve the accuracy and efficiency of the conversion, and reduce errors.
[0130] Furthermore, the device also includes an adding module, which is used to:
[0131] Add the target encoding string to the path address data.
[0132] In the above implementation process, adding the target encoding string to the value path address data can provide traversal for the use of the serial port screen and reduce the garbled code phenomenon.
[0133] The above-mentioned serial port screen coding format conversion device can implement the method of the above-mentioned embodiment 1. The optional items in the above-mentioned embodiment 1 are also applicable to this embodiment and will not be described in detail here.
[0134] The rest of the contents of the embodiments of the present application can refer to the contents of the above-mentioned embodiment 1, and will not be repeated in this embodiment.
[0135] Embodiment 3
[0136] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the serial port screen encoding format conversion method of embodiment one.
[0137] Optionally, the above-mentioned electronic device may be a server.
[0138] See also Figure 3 , Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include a processor 31, a communication interface 32, a memory 33 and at least one communication bus 34. The communication bus 34 is used to realize direct connection and communication between these components. The communication interface 32 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The processor 31 may be an integrated circuit chip with signal processing capabilities.
[0139] The processor 31 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor 31 can also be any conventional processor, etc.
[0140] The memory 33 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 33 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 31, the device can execute the above-mentioned Figure 1 The method embodiment involves various steps.
[0141] Optionally, the electronic device may further include a storage controller and an input / output unit. The memory 33, the storage controller, the processor 31, the peripheral interface, and the input / output unit are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components may be electrically connected to each other via a communication bus 34. The processor 31 is used to execute executable modules stored in the memory 33, such as software function modules or computer programs included in the device.
[0142] The input and output unit is used to provide users with the task creation and to create an optional time period or preset execution time for the task to enable interaction between the user and the server. The input and output unit can be, but is not limited to, a mouse and a keyboard.
[0143] Understandably, Figure 3 The structure shown is for illustration only. The electronic device may also include Figure 3 More or fewer components as shown, or with Figure 3 Different configurations shown. Figure 3 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0144] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the serial port screen encoding format conversion method of embodiment one is implemented.
[0145] The embodiment of the present application also provides a computer program product, which, when running on a computer, enables the computer to execute the method described in the method embodiment.
[0146] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented with a dedicated hardware-based device that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0147] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0148] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0149] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0150] The above is only a specific implementation of the present application, but the protection range of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical range disclosed in the present application, which should be included in the protection range of the present application. Therefore, the protection range of the present application should be based on the protection range of the claims.
[0151] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for converting serial port screen encoding format, characterized in that: The method comprises: Constructing a target format mapping file, wherein the target format mapping file includes a mapping relationship between the first format and the second format; Obtaining the path address data of the target format mapping file according to the first function; Traversing the characters in the target format mapping file according to the path address data to obtain a code value in a first format; Obtaining, according to the mapping relationship, a code value in a second format corresponding to the code value in the first format; A target encoded character string is obtained according to the encoded value in the second format.
2. The method for converting the serial port screen encoding format according to claim 1, characterized in that: The step of traversing the characters in the target format mapping file according to the path address data to obtain the encoding value of the first format includes: Determining whether the path address data meets a first threshold; If yes, no encoding format conversion is performed; If not, the target format mapping file is opened and traversed according to the second function to obtain the encoding value of the first format.
3. The method for converting the serial port screen encoding format according to claim 2, characterized in that: The step of opening the target format mapping file according to the second function to traverse and obtain the encoding value of the first format includes: Open the target format mapping file according to the second function, and read the character string in the target format mapping file; Traverse each character in the string to obtain a length variable of each character; The encoding value of the first format is obtained according to the length variable of each character.
4. The method for converting the serial port screen encoding format according to claim 3, characterized in that: The step of obtaining the encoding value of the first format according to the length variable of each character comprises: Divide each character according to the length variable to obtain multiple groups of characters, each group of characters corresponding to a length variable; Get the encoding value of the first format corresponding to the length variable of each group of characters.
5. The method for converting the serial port screen encoding format according to claim 1, characterized in that: The step of obtaining, according to the mapping relationship, a code value in a second format corresponding to the code value in the first format comprises: Determine whether the encoding value of the first format is greater than a second threshold; If so, searching, according to the mapping relationship, for a code value in the second format corresponding to the code value in the first format; If not, the encoded value in the first format is not converted.
6. The method for converting the serial port screen encoding format according to claim 1, characterized in that: The step of obtaining a target encoded string according to the encoded value in the second format comprises: Moving the file pointer corresponding to the encoding value in the second format to a target position according to a third function; Read the byte data at the target position according to a fourth function; The byte data is converted into the target encoded character string according to a fifth function.
7. The method for converting the serial port screen encoding format according to claim 6, characterized in that: After the step of obtaining the target encoded string according to the encoded value in the second format, the method further includes: The target encoding character string is added to the path address data.
8. A serial port screen coding format conversion device, characterized in that: The device comprises: A construction module, configured to construct a target format mapping file, wherein the target format mapping file includes a mapping relationship between a first format and a second format; A data acquisition module, used to obtain the path address data of the target format mapping file according to the first function; further used to traverse the characters in the target format mapping file according to the path address data to obtain the encoding value of the first format; further used to obtain the encoding value of the second format corresponding to the encoding value of the first format according to the mapping relationship; A conversion module is used to obtain a target encoding character string according to the encoding value in the second format.
9. An electronic device, characterized in that: It includes a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the serial port screen encoding format conversion method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements the serial port screen encoding format conversion method as described in any one of claims 1 to 7.