Method and device for detecting messy codes in document

文档序号:169323 发布日期:2021-10-29 浏览:24次 中文

阅读说明:本技术 一种检测文档中乱码的方法及装置 (Method and device for detecting messy codes in document ) 是由 孙自刚 于 2020-04-29 设计创作,主要内容包括:本发明公开了一种检测文档中乱码的方法及装置,本发明实施例获取嵌入式设备当前支持语言的字库并加载后,依次读取文档的字符编码集合中的每个字符编码,针对每个字符编码,判断是否在嵌入式设备当前加载的语言数据库中存在,如果否,得到所述字符编码为乱码的检测信息,如果是,检测下一个字符编码,直到文档的字符编码集合中的所有字符编码被判断完;汇总文档中的所有字符编码为乱码的检测信息,输出。这样,本发明实施例实现了对文档的字符编码集合中的每个字符编码的乱码检测,且将得到的最终检测信息输出给用户查看,增加了用户体验度。(The invention discloses a method and a device for detecting messy codes in a document, wherein after a word stock of a current support language of an embedded device is obtained and loaded, each character code in a character code set of the document is read in sequence, whether the character code exists in a language database loaded by the embedded device at present is judged aiming at each character code, if not, the detection information that the character code is the messy code is obtained, if so, the next character code is detected until all the character codes in the character code set of the document are judged; and summarizing all character codes in the document into detection information of messy codes and outputting the detection information. Therefore, the method and the device for detecting the messy codes of the character codes in the character code set of the document realize the messy code detection of each character code in the character code set of the document, output the obtained final detection information to a user for checking, and increase the user experience.)

1. A method of detecting scrambling code in a document, the method comprising:

acquiring and loading a word stock of a current support language of the embedded equipment;

reading each character code in a character code set of a document in sequence;

judging whether the character codes exist in the loaded word stock or not aiming at each character code, and if not, obtaining the detection information that the character codes are messy codes;

and summarizing all character codes in the document into detection information of messy codes and outputting the detection information.

2. The method of claim 1, wherein the determining whether it exists in the loaded word stock further comprises:

a. judging that the word exists in the loaded word stock;

b. judging whether the next character code in the character code set exists in the loaded word stock, if not, executing the step c; if yes, executing step d;

c. obtaining detection information of the character codes as messy codes;

d. and returning to the step b to continue the execution until all the character codes in the character code set of the document are judged.

3. The method of claim 1 or 2, wherein said determining whether there is a presence in the loaded word stock comprises:

the loaded word stock records the mapping relation between the character codes and the current language text;

and judging whether the loaded word stock has the character code which is the same as the read character code.

4. The method of claim 1 or 2, wherein the obtaining and loading a word stock of a current supported language of the embedded device further comprises:

the number of the embedded device support languages is multiple;

one of the embedded equipment support languages is used as the current support language of the embedded equipment in sequence;

and acquiring and loading a word stock of the current support language of the embedded device.

5. The method of claim 1 or 2, wherein the method further comprises:

converting the character code set of the document into language text of a current support language of the embedded equipment;

and marking the messy codes in the language text according to the detection information that all character codes in the summary document are messy codes.

6. An apparatus for detecting scrambling code in a document, comprising: a loading unit, a reading unit, a detecting unit and an output unit, wherein,

the loading unit is used for acquiring and loading a word stock of the current support language of the embedded equipment;

the reading unit is used for sequentially reading each character code in the character code set of the document;

the detection unit is used for judging whether the character codes exist in the loaded word stock or not aiming at each character code, and if not, the detection information that the character codes are messy codes is obtained;

and the output unit is used for summarizing the detection information of all the character codes in the document into messy codes and outputting the detection information.

7. The apparatus of claim 6, wherein the detection unit is further configured to:

a. judging that the word exists in the loaded word stock;

b. judging whether the next character code in the character code set exists in the loaded word stock, if not, executing the step c; if yes, executing step d;

c. obtaining detection information of the character codes as messy codes;

d. and returning to the step b to continue the execution until all the character codes in the character code set of the document are judged.

8. The apparatus of claim 6 or 7, wherein the detection unit is further configured to:

the loaded word stock records the mapping relation between the character codes and the current language text;

and judging whether the loaded word stock has the character code which is the same as the read character code.

9. The apparatus of claim 6 or 7, wherein the loading unit is further configured to:

the number of the embedded device support languages is multiple; one of the embedded equipment support languages is used as the current support language of the embedded equipment in sequence; and acquiring and loading a word stock of the current support language of the embedded device.

10. The apparatus according to claim 6 or 7, further comprising a conversion unit for converting the character code set of the document into language text of a language currently supported by the embedded device;

and the output unit is also used for marking out messy codes in the language text according to the detection information that all character codes in the summary document are messy codes.

Technical Field

The invention relates to a technology for processing a document by an embedded device, in particular to a method and a device for detecting messy codes in the document.

Background

The embedded device is a device which is set by taking application as a center and taking computer technology as a basis, and the application system is suitable for a special computer system with special requirements on the aspects of function, reliability, cost, volume, power consumption and the like. In embedded device applications, documents are stored in embedded devices in the form of character code sets or transmitted between embedded devices. When a certain document is displayed on a certain embedded device, firstly, loading a word stock of a supported language in the embedded device, and storing a mapping relation between character codes and language texts in the word stock; then, the embedded device reads the stored document or receives the document transmitted by the remote embedded device, the document exists in the form of character code set, and each character code in the character code set is converted into the language text according to the mapping relation in the character, and the language text is displayed. However, when each character code in the character code set of the document is converted into the language text, one or more character codes may be converted incorrectly, thereby causing a messy code in the displayed language text and affecting the user experience of browsing the language text.

In order to avoid the messy codes of the document when the document is displayed, the document needs to be detected. At present, a document overall detection mode is usually adopted for detecting a document, for example, whether a character code set of the document is damaged or not is checked before the document is opened, whether a read document character code set is complete or not is checked, and whether a messy code appears in the overall document during display is confirmed. However, the overall document detection method cannot specifically perform the messy code detection on each character code in the character code set of the document, so that even if the document passing the overall document detection is displayed, the messy code still exists.

Disclosure of Invention

In view of the above, the present invention provides a method for detecting a garbled code in a document, which is capable of performing garbled code detection on a conversion of each character code in a character code set of the document.

The embodiment of the invention also provides a device for detecting the messy codes in the document, which can detect the messy codes of the conversion of each character code in the character code set of the document.

The embodiment of the invention is realized as follows:

a method of detecting scrambling code in a document, the method comprising:

acquiring and loading a word stock of a current support language of the embedded equipment;

reading each character code in a character code set of a document in sequence;

judging whether the character codes exist in the loaded word stock or not aiming at each character code, and if not, obtaining the detection information that the character codes are messy codes;

and summarizing all character codes in the document into detection information of messy codes and outputting the detection information.

Preferably, the determining whether the word exists in the loaded word stock further includes:

a. judging that the word exists in the loaded word stock;

b. judging whether the next character code in the character code set exists in the loaded word stock, if not, executing the step c; if yes, executing step d;

c. obtaining detection information of the character codes as messy codes;

d. and returning to the step b to continue the execution until all the character codes in the character code set of the document are judged.

Preferably, the determining whether there is a presence in the loaded word stock comprises:

the loaded word stock records the mapping relation between the character codes and the current language text;

and judging whether the loaded word stock has the character code which is the same as the read character code.

Preferably, the acquiring and loading a word stock of a current support language of the embedded device further includes:

the number of the embedded device support languages is multiple;

one of the embedded equipment support languages is used as the current support language of the embedded equipment in sequence;

and acquiring and loading a word stock of the current support language of the embedded device.

Preferably, the method further comprises:

converting the character code set of the document into language text of a current support language of the embedded equipment;

and marking the messy codes in the language text according to the detection information that all character codes in the summary document are messy codes.

An apparatus for detecting scrambling code in a document, comprising: a loading unit, a reading unit, a detecting unit and an output unit, wherein,

the loading unit is used for acquiring and loading a word stock of the current support language of the embedded equipment;

the reading unit is used for sequentially reading each character code in the character code set of the document;

the detection unit is used for judging whether the character codes exist in the loaded word stock or not aiming at each character code, and if not, the detection information that the character codes are messy codes is obtained;

and the output unit is used for summarizing the detection information of all the character codes in the document into messy codes and outputting the detection information.

Preferably, the detection unit is further configured to:

a. judging that the word exists in the loaded word stock;

b. judging whether the next character code in the character code set exists in the loaded word stock, if not, executing the step c; if yes, executing step d;

c. obtaining detection information of the character codes as messy codes;

d. and returning to the step b to continue the execution until all the character codes in the character code set of the document are judged.

Preferably, the detection unit is further configured to:

the loaded word stock records the mapping relation between the character codes and the current language text;

and judging whether the loaded word stock has the character code which is the same as the read character code.

Preferably, the loading unit is further configured to:

the number of the embedded device support languages is multiple; one of the embedded equipment support languages is used as the current support language of the embedded equipment in sequence; and acquiring and loading a word stock of the current support language of the embedded device.

The conversion unit is used for converting the character code set of the document into language text of a current support language of the embedded equipment;

and the output unit is also used for marking out messy codes in the language text according to the detection information that all character codes in the summary document are messy codes.

As seen from the above, after acquiring and loading the word stock of the current supported language of the embedded device, the embodiment of the present invention sequentially reads each character code in the character code set of the document, and judges whether the character code exists in the language database currently loaded by the embedded device for each character code, if not, obtains the detection information that the character code is a messy code, and if so, detects the next character code until all the character codes in the character code set of the document are judged; and summarizing all character codes in the document into detection information of messy codes and outputting the detection information. Therefore, the method and the device for detecting the messy codes of the character codes in the character code set of the document realize the messy code detection of each character code in the character code set of the document, output the obtained final detection information to a user for checking, and increase the user experience.

Drawings

FIG. 1 is a flowchart of a method for detecting a garbled code in a document according to an embodiment of the present invention;

FIG. 2 is a flowchart of a method for determining whether a character code exists in the loaded word stock according to an embodiment of the present invention;

fig. 3 is a flowchart of a method for acquiring and loading a word stock of a current support language of an embedded device according to an embodiment of the present invention;

FIG. 4 is a schematic structural diagram of an apparatus for detecting a scrambling code in a document according to an embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to the accompanying drawings and examples.

It can be seen from the background art that the existing messy code detection mode for the document adopts a document overall detection mode, and the messy code detection cannot be performed on each character code in the character code set of the document, so that the obtained detection result is inaccurate, and the true situation of the messy code in the document cannot be reflected. In order to overcome the problem, the embodiment of the invention obtains and loads a word stock of a current support language of the embedded device, sequentially reads each character code in a character code set of a document, judges whether the character code exists in the language database loaded by the embedded device currently aiming at each character code, if not, obtains detection information that the character code is a messy code, if so, detects the next character code until all the character codes in the character code set of the document are judged; and summarizing all character codes in the document into detection information of messy codes and outputting the detection information.

Therefore, the method and the device for detecting the messy codes of the character codes in the character code set of the document realize the messy code detection of each character code in the character code set of the document, output the obtained final detection information to a user for checking, and increase the user experience.

Fig. 1 is a flowchart of a method for detecting a messy code in a document according to an embodiment of the present invention, which includes the following steps:

step 101, acquiring and loading a word stock of a current support language of the embedded equipment;

step 102, reading each character code in a character code set of a document in sequence;

103, judging whether the character codes exist in the loaded word stock or not aiming at each character code, and if not, obtaining detection information that the character codes are messy codes;

and step 104, summarizing all character codes in the document into detection information of messy codes and outputting the detection information.

Fig. 2 shows a flowchart of the method for determining whether the loaded word stock exists in step 103 of the method, which includes the following specific steps:

step 201, reading a character code in a character code set of a document according to the sequence, judging whether the character code exists in the loaded word stock, and if not, executing step 202; if yes, go to step 203;

step 202, obtaining the detection information of the character code as the messy code, and continuing to execute step 203;

step 203, judging whether the next character code in the character code set exists in the loaded word stock, if not, executing step 204; if yes, go to step 205;

step 204, obtaining the detection information that the character code is a messy code, and turning to step 205;

step 205, determining whether all character codes in the character code set of the document are judged, if yes, executing step 206; if not, returning to the step 203 to continue the execution;

and step 206, summarizing all character codes in the document into detection information of messy codes.

Thus, after the detection process of fig. 2, the messy code detection is performed on each character code in the document, and the whole process is executed circularly until the last character code in the document is detected by the messy code, so that the messy code detection accuracy of the document is increased.

In the process of fig. 2, the order of judging each character code in the character code set is determined according to the order of the character codes appearing in the document, so that the last character code appearing in the document is also detected last, and after the character codes are summarized and when the document is marked, the character codes can be marked and displayed according to the order, so that no error is marked, the messy code detection rate of the document is increased, and the method is easy to implement. Of course, the order of judging each character code in the character code set may also be determined not according to the order in which the character codes appear in the document, but randomly or according to a set judgment order rule, and the judgment is performed according to the need, as long as all the character codes in the character code set are ensured to be detected, the judgment is more flexible by adopting the method, and the user experience is enhanced.

In the method of fig. 1, specifically determining whether each character code of a document exists in the loaded word stock comprises: the loaded word stock records the mapping relation between the character codes and the current language text; and judging whether the loaded word stock has the character code which is the same as the read character code. Therefore, the embodiment of the invention presets the corresponding relation between the character codes and the current language text, directly utilizes the mapping relation in the existing word stock in the judging process, simply performs the messy code detection on each character code in the document and is easy to implement.

In the embodiment of the invention, the embedded device can not only support one language, but also support a plurality of languages, for each language, a corresponding word stock exists, and when a document is to be displayed, a corresponding language text is displayed under a certain language environment supported by the embedded device. When a document is subjected to messy code detection, the language environment of the document needs to be determined, because messy codes exist in the document under a certain language environment, and messy codes may not exist in the document under another language environment.

When there are multiple languages supported by the embedded device, how to specifically implement the detection process of character encoding in a document under each language environment is shown in fig. 3, where fig. 3 is a flowchart of a method for acquiring and loading a word stock of a current supported language of the embedded device according to an embodiment of the present invention, and the specific steps are as follows:

step 301, supporting multiple languages by the embedded device;

step 302, one of the support languages of the embedded device is sequentially used as the current support language of the embedded device;

303, acquiring and loading a word stock of the current support language of the embedded equipment, and performing a messy code detection process of the document;

step 304, judging whether the messy code detection process of the document is finished, if so, executing step 305; if not, go to step 306;

step 305, returning to step 302 to continue execution until all languages supported by the embedded device are selected;

and step 306, continuing to detect the messy codes of the document, and returning to the step 304 for execution.

As can be seen from fig. 3, when detecting the garbled codes in the document, the embodiments of the present invention can be performed in different language environments, and only the supported language environment is switched before the determination, so that the garbled code detection of the document can be performed in a multi-language environment, and the application range of the garbled code detection is wide.

Of course, since the user knows which language needs to be used to display the document, on the basis of fig. 3, the user may also actively select a language as the language currently supported by the embedded device and load the corresponding word stock to execute the messy code detection process of the document, so that the messy code detection of the document is not required to be performed in sequence under multiple language environments, which is simpler and faster.

In step 104 shown in fig. 1, there are various ways of outputting the detection information in which all characters in the summarized document are encoded as the messy codes, for example, the detection information is directly displayed to the user, or the displayed document may be displayed in a manner of highlighting or different colors, so that the user can more easily know the messy codes in the document. According to the user needs, one of the detection information modes for outputting the messy codes is adopted, so that the user can more quickly and accurately know the messy codes detected in the document, and the user experience is improved.

Specifically, the scrambling code manner in the output document may include:

converting the character code set of the document into language text of a current support language of the embedded equipment;

and marking the messy codes in the language text according to the detection information that all character codes in the summary document are messy codes.

The embodiment of the present invention will be described with reference to a specific example.

Assuming that the language supported by the embedded device is Thai, a word stock of Thai is loaded, and a character code set of a document is read and converted to display a corresponding Thai text, for example, the Thai text expected to be displayed is:

!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

however, because of some factors, the character encoding set of the document is converted to display the corresponding Thai text as follows:

!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

that is, a character in the middle becomes a question mark? ", a scrambling code is present. This is less easily recognizable to the user.

After the method provided by the embodiment of the invention is adopted to test the document, the detection information of the messy codes of the character codes can be obtained and provided for the user, so that the user can easily know the position of the messy codes in the document and the specific content of the messy codes, the identification accuracy of the messy codes is improved, and the user experience is improved.

Fig. 4 is a schematic structural diagram of an apparatus for detecting a messy code in a document according to an embodiment of the present invention, including: a loading unit, a reading unit, a detecting unit and an output unit, wherein,

the loading unit is used for acquiring and loading a word stock of the current support language of the embedded equipment;

the reading unit is used for sequentially reading each character code in the character code set of the document;

the detection unit is used for judging whether the character codes exist in the loaded word stock or not aiming at each character code, and if not, the detection information that the character codes are messy codes is obtained;

and the output unit is used for summarizing the detection information of all the character codes in the document into messy codes and outputting the detection information.

The device realizes the messy code detection of each character code in the character code set of the document, and outputs the obtained final detection information to a user for checking, thereby increasing the user experience.

In the apparatus, the detection unit is further configured to:

a. judging that the word exists in the loaded word stock;

b. judging whether the next character code in the character code set exists in the loaded word stock, if not, executing the step c; if yes, executing step d;

c. obtaining detection information of the character codes as messy codes;

d. and returning to the step b to continue the execution until all the character codes in the character code set of the document are judged.

Therefore, the detection unit detects the messy codes of each character code in the document, the whole process is executed circularly until the last character code in the document is detected by the messy codes, and the messy code detection accuracy of the document is improved.

Further, in the apparatus, the detecting unit is further configured to: the loaded word stock records the mapping relation between the character codes and the current language text; and judging whether the loaded word stock has the character code which is the same as the read character code. The specific detection mode of each character code in the document by the detection unit is clarified. Under the condition, the device presets the corresponding relation between the character codes and the current language text, directly utilizes the mapping relation in the existing word stock in the judging process, simply carries out messy code detection on each character code in the document and is easy to implement.

Further, in the apparatus, the loading unit is further configured to: the number of the embedded device support languages is multiple; one of the embedded equipment support languages is used as the current support language of the embedded equipment in sequence; and acquiring and loading a word stock of the current support language of the embedded device. The method and the device have the advantages that the messy code detection of the character codes in the document is respectively carried out under different language environments supported by the embedded device, the messy code detection of the character codes in the document is not only carried out under one language environment, and the messy code detection range of the document is enlarged. In this case, the device can detect the messy codes in the document in different language environments, and only needs to switch the supported language environment before judgment, so that the messy code detection of the document can be performed in a multi-language environment, and the application range of the messy code detection is wide.

Furthermore, in the device, there are multiple detection information modes for outputting all character codes in the summary document as messy codes, and one of the detection information modes for outputting the messy codes can be adopted according to the needs of the user, so that the user can more quickly and accurately know the messy codes detected in the document, and the user experience is improved. Specifically, one of them is: the conversion unit is used for converting the character code set of the document into language text of a current support language of the embedded equipment; and the output unit is also used for marking out messy codes in the language text according to the detection information that all character codes in the summary document are messy codes.

The method and the device can perform messy code detection on each character code in the character code set of the document, and provide the detection result for the user so that the user can know the detection result in time, and the user experience is improved.

The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

12页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于NODEJS应用的文件转换解析方法、系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!