Communication packaging method and system supporting uncommon fonts
By storing uncommon words in the UTF-8 encoding form in the data source and converting them into BASE64 encoding form, the problems of UTF-8 encoding complexity and high cost in the prior art that are transformed into supporting uncommon words are solved, and the problem of high cost in the UTF-8 encoding that is transformed into supporting uncommon words in the prior art is realized. The old application system supports the transmission and display of rare words.
Patent Information
- Application Number
- CN202411430909.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2025-02-14
AI Technical Summary
When the prior art is transformed into UTF-8 encoding that supports rare characters, it is necessary to transform the various module components of the system as a whole, resulting in high complexity and difficulty in transformation and high development and testing costs.
By storing UTF-8 encoding in the data source and converting it into BASE64 encoding, encapsulating it as a communication message and passing it to the client, decoding it using the page rendering component and selecting the corresponding font from the system font library for display .
It supports the transmission and display of rare words without the need to transform the intermediate layer, reducing the complexity and cost of system transformation.
Smart Images

Figure CN119443046A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of digital communication technology, and in particular to a communication packaging method and system supporting rare fonts. Background Art
[0002] GBK Chinese encoding is the full name of "Chinese Character Internal Code Extension Specification", which is a Chinese character encoding specification formulated by the National Information Technology Standardization Technical Committee of the People's Republic of China on December 1, 1995. GBK encoding has good compatibility and a wide range of applications.
[0003] Due to historical reasons, such as Figure 1 As shown in the figure, traditional old application systems mostly use GBK Chinese encoding for the storage and transmission of Chinese information, and do not support UTF-8 encoding. However, traditional GBK encoding is difficult to support a large number of rare characters, because GBK encoding cannot cover all rare characters. In order to support rare characters, the conventional practice of existing old application systems when doing rare character transformation is to transform the entire system upstream and downstream into UTF8 encoding. Since traditional old systems are adapted to GBK encoding, transformation to UTF8 encoding requires that all module components of the system be transformed to support rare characters.
[0004] As the number of system links increases, the complexity and difficulty of this transformation will increase. Any incomplete transformation of any component will affect the final implementation effect. In addition, the corresponding development and testing costs will also increase exponentially with the increase in system complexity.
[0005] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The main purpose of this application is to provide a communication encapsulation method and system that supports rare fonts, aiming to solve the technical problems that in the existing technical solutions, the UTF-8 encoding that supports rare characters needs to be modified in each module of the system to support rare characters, resulting in high complexity and difficulty of the modification, and high development and testing costs.
[0007] In view of the above technical shortcomings, the main purpose of the present invention is to provide a communication encapsulation method supporting rare fonts, comprising:
[0008] According to the client's rare character request, the corresponding rare characters in UTF-8 encoding are called from the data source;
[0009] Convert rare characters from UTF-8 encoding to BASE64 encoding;
[0010] Encapsulate the rare characters in BASE64 encoding into a communication message and transmit it to the client;
[0011] Use the client's page rendering component to decode the rare characters in BASE64 encoding to obtain the rare characters in UTF-8 encoding;
[0012] Select fonts corresponding to rare characters from the system font library to display the rare characters.
[0013] Preferably, in the above communication encapsulation method, the step of converting the uncommon characters from the UTF-8 encoding form to the BASE64 encoding form comprises:
[0014] Convert rare characters from UTF-8 encoding to byte form;
[0015] The base64 module of the python language is used to perform BASE64 encoding on the rare characters in byte form according to the BASE64 algorithm to obtain the rare characters in BASE64 encoded form, wherein the base64 module encapsulates the BASE64 algorithm.
[0016] Preferably, in the above communication encapsulation method, the step of using the client's page rendering component to decode the rare characters in BASE64 encoding to obtain the rare characters in UTF-8 encoding includes:
[0017] Set the UTF-8 encoding format of the decoded output in the page rendering component;
[0018] Define the decoding method in the page rendering component and use the decoding method to encapsulate the UTF-8 encoding format;
[0019] Decode the rare characters in BASE64 encoding into rare characters in UTF-8 encoding using a decoding method;
[0020] Define the rendering method in the page rendering component and encapsulate the rendering effect in the rendering method;
[0021] Using the rendering method, the rare characters in UTF-8 format are rendered according to the rendering effect to obtain the rare characters in UTF-8 encoded format after rendering.
[0022] Preferably, in the above communication encapsulation method, the step of selecting a font corresponding to an uncommon character from a system character library and displaying the uncommon character comprises:
[0023] Use inline styles to define font display instances in the rendering method;
[0024] Use font display examples to encapsulate fonts corresponding to uncommon characters;
[0025] Use the rendering method to apply the font to the decoded result.
[0026] Preferably, in the above communication encapsulation method, the step of encapsulating the rare characters in BASE64 encoding form into a communication message and transmitting it to the client comprises:
[0027] Generate encryption and decryption keys using client authentication information;
[0028] Use the encryption and decryption key to encrypt the rare characters in BASE64 encoding to obtain an encrypted communication message;
[0029] Negotiate with the client to generate a transmission key;
[0030] The encrypted communication message is transmitted to the client using the transmission key, so that the client uses the encryption and decryption key to decrypt the communication message and obtain the BASE64 code of the rare character.
[0031] Preferably, in the above communication encapsulation method, the step of calling the corresponding uncommon characters in UTF-8 encoding from the data source according to the uncommon characters request of the client comprises:
[0032] Obtain the query key value of the rare character from the rare character request of the client;
[0033] Determine the Value corresponding to the query key value in the form of a key-value pair;
[0034] Call the rare character in UTF-8 encoding corresponding to the Value value from the data source.
[0035] Preferably, the communication encapsulation method further comprises, before the step of calling the corresponding uncommon characters in UTF-8 encoding form from the data source according to the uncommon character request of the client:
[0036] A rare character table is stored in a data source, and the storage locations of all rare characters in the rare character table in the data source are sent to a client;
[0037] The storage location of the rare characters in the data source is used as the Value value and stored in the client in the form of key-value pairs.
[0038] To achieve the above purpose, the present application also provides a communication encapsulation system supporting rare characters, the system comprising: a backend server and a client; the backend server comprises a data source and a backend application; the client comprises a page rendering component and a system character library; wherein,
[0039] The data source stores rare characters in UTF-8 encoding;
[0040] A backend application is used to call the corresponding rare characters in UTF-8 encoding form from the data source according to the rare characters request of the client, and convert the rare characters from UTF-8 encoding form to BASE64 encoding form;
[0041] The page rendering component is used to decode rare characters in BASE64 encoding, obtain rare characters in UTF-8 encoding, and select corresponding fonts from the system font library to display rare characters.
[0042] Preferably, in the above-mentioned communication encapsulation system, the page rendering component is specifically used to: define a decoding method, and use the decoding method to encapsulate the UTF-8 encoding form; use the decoding method to decode the rare characters in the BASE64 encoding form into the rare characters in the UTF-8 encoding form; define a rendering method, and encapsulate the rendering effect in the rendering method; use the rendering method to render the rare characters in the UTF-8 form according to the rendering effect, and obtain the rendered rare characters in the UTF-8 encoding form.
[0043] Preferably, in the above-mentioned communication encapsulation system, the background server also includes a middle-office application, which is used to generate encryption and decryption keys using the client's identity authentication information; use the encryption and decryption keys to encrypt rare characters in BASE64 encoding to obtain encrypted communication messages; negotiate with the client to generate a transmission key; and use the transmission key to transmit the encrypted communication message to the client.
[0044] One or more technical solutions proposed in this application have at least the following technical effects:
[0045] The data source stores rare characters in UTF-8 encoding. When receiving a rare character request from a client, the rare character can be called from the data source. Because the traditional old application system cannot directly support UTF-8 encoding, it is necessary to convert the rare character from UTF-8 encoding to BASE64 encoding. The rare characters in BASE64 encoding can be applied to both UTF-8 encoding and GBK encoding. In UTF-8 encoding or GBK encoding, the BASE64 encoding form of the rare character is a number and / or a letter, so it can be transmitted in the old application system that can only be applied to GBK encoding. In this way, the rare characters in BASE64 encoding are encapsulated as communication messages and can be transmitted to the client of the old application system. The rare characters in BASE64 encoding are converted into the original UTF-8 encoding form by using the page rendering component of the client. In this way, the original rare character information can be obtained without causing the loss of rare character information. Finally, the font corresponding to the uncommon character is selected from the system font library to display the uncommon character, so that the uncommon character requested by the customer can be displayed clearly and completely. The above technical solution of the present application does not require any modification of the middle layer that uses non-UTF-8 encoding for communication. It only needs to modify the input and output ends of the old application system that cannot apply UTF-8 encoding to support uncommon characters, which can greatly reduce the complexity of system modification and save system application modification and testing costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0048] Figure 1 A schematic diagram of the structure of an old application system that does not support UTF-8 encoding provided by the prior art;
[0049] Figure 2 A flow chart of a communication packaging method supporting rare fonts provided in an embodiment of the present application;
[0050] Figure 3 for Figure 2 A flowchart of a method for calling an uncommon character in UTF-8 encoding provided by the illustrated embodiment;
[0051] Figure 4 A flowchart of a key-value pair storage method for rare characters provided in an embodiment of the present application;
[0052] Figure 5 for Figure 2 A schematic flow chart of a method for converting the encoding form of an uncommon character provided in the illustrated embodiment;
[0053] Figure 6 yes Figure 2 A schematic flow chart of a communication packaging method for rare characters provided in the illustrated embodiment;
[0054] Figure 7 yes Figure 2 A flowchart of a method for decoding rare characters in BASE64 encoding provided by the illustrated embodiment;
[0055] Figure 8 yes Figure 2 A schematic flow chart of a method for displaying rare characters provided in the illustrated embodiment;
[0056] Fig. 9 It is a structural schematic diagram of a communication encapsulation system provided in an embodiment of the present application.
[0057] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0058] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0059] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0060] The technical problems existing in the prior art are as follows:
[0061] Due to historical reasons, most old application systems use GBK Chinese encoding for the storage and transmission of Chinese information, and do not support UTF-8 encoding. However, traditional GBK encoding is difficult to support a large number of rare characters, because GBK encoding cannot cover all rare characters. In order to support rare characters, the conventional practice of existing old application systems when doing rare character transformation is to transform the entire system upstream and downstream to UTF8 encoding. Since the traditional old system is adapted to GBK encoding, the transformation to UTF8 encoding requires that all module components of the system be transformed to support rare characters. With the increase of system links, the complexity and difficulty of this transformation will increase. Any incomplete transformation of any component will affect the final implementation effect; in addition, the corresponding development and testing costs will also increase exponentially with the increase of system complexity.
[0062] In order to solve the above technical problems, the present application provides a communication encapsulation solution that supports uncommon fonts. It only needs to modify the input and output ends of the old application system to convert the uncommon characters in the UTF-8 encoding form in the data source into the BASE64 encoding form. It does not need to modify the middle layer. The middle layer can also use the GBK encoding method for encoding and communication encapsulation. When the communication message is transmitted to the client, it is only necessary to decode the uncommon characters in the BASE64 encoding form in the rendering component, restore the uncommon characters in the UTF-8 encoding form, and use the fonts in the system font library for display. In summary, this method does not need to modify the middle layer that uses non-UTF-8 encoding for communication. It only needs to modify the input and output ends to support uncommon characters.
[0063] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device that can realize the above functions, a computer-readable storage medium, etc.
[0064] In order to better understand the above technical solution, the exemplary embodiments of the present application will be described in more detail with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments shown here. On the contrary, these embodiments are provided to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0065] To achieve the above technical objectives, see Figure 2 , Figure 2 The present invention provides a flow chart of a communication packaging method supporting rare fonts. Figure 2 As shown, the communication encapsulation method supporting rare fonts includes:
[0066] S110: According to the rare character request of the client, the corresponding rare characters in UTF-8 encoding are called from the data source. The communication encapsulation system is suitable for traditional old application systems that do not support UTF-8 encoding, and the system includes a background server and a client. The background server includes a data source, and the data source stores a rare character table, and the rare character table contains rare characters encoded in UTF-8. When the background server obtains the rare character request of the client, it will call the rare character in UTF-8 encoding from the data source according to the rare character request, thereby realizing the transformation of the input and output ends of the background server so that the system supports UTF-8 encoding.
[0067] Specifically, as a preferred embodiment, Figure 3 As shown, the above step S110: according to the rare character request of the client, calling the corresponding rare character in UTF-8 encoding form from the data source includes:
[0068] S111: Obtaining a query key value of an uncommon character from an uncommon character request from a client;
[0069] S112: Determine the Value corresponding to the query key value in the form of a key-value pair;
[0070] S113: Call the rare character in UTF-8 encoding corresponding to the Value from the data source.
[0071] The technical solution provided by the embodiment of the present application stores the query key value of the rare character on the client in the form of a key-value pair, wherein the query key value includes the pinyin, voice and handwriting of the rare character, and the key-value pair contains the Value value of the rare character, and the rare character in the data source is stored corresponding to the Value value and the UTF-8 encoded form, so that the rare character can be extracted from the data source to obtain the rare character required for the above-mentioned rare character request.
[0072] In order to quickly and accurately retrieve the uncommon characters from the data source, the present application stores the uncommon characters in the data source in the form of an uncommon character table, and uses the storage position of the uncommon characters in the data source, such as row X and column X of the uncommon character table, as the above-mentioned Value value.
[0073] Specifically, as a preferred embodiment, Figure 4 As shown, the communication encapsulation method, before step S110: calling the corresponding uncommon characters in UTF-8 encoding form from the data source according to the uncommon character request of the client, further comprises:
[0074] S201: storing a rare character table in a data source, and sending the storage locations of all rare characters in the rare character table in the data source to a client;
[0075] S202: The storage location of the rare characters in the data source is used as the Value value and stored in the client in the form of a key-value pair.
[0076] The technical solution provided in the embodiment of the present application stores all the rare characters in the form of a rare character table in a data source, and then sends the storage location of the rare characters to the client. The client uses the storage location of the rare characters in the data source as the Value value, so that the Value value can be bound to the query key value in the form of a key-value pair in the client, so that the user can quickly and accurately query the above rare characters.
[0077] Figure 2 The technical solution provided by the illustrated embodiment, after calling the rare characters in UTF-8 encoding form from the data source, further includes:
[0078] S120: Convert the rare characters from the UTF-8 encoding format to the BASE64 encoding format.
[0079] This application needs to use the BASE64 algorithm to convert the encoding form of the rare characters encoded in UTF-8. It can be implemented using Python, JavaScript or Java programming languages.
[0080] Specifically, as a preferred embodiment, Figure 5 As shown, in the above communication encapsulation method, step S120: the step of converting the uncommon characters from the UTF-8 encoding form to the BASE64 encoding form includes:
[0081] S121: Convert rare characters from UTF-8 encoding form to byte form.
[0082] S122: using a base64 module of the python language, and performing base64 encoding on the rare characters in byte form according to a base64 algorithm to obtain the rare characters in base64 encoded form, wherein the base64 module encapsulates the base64 algorithm.
[0083] UTF-8 is a variable-length character encoding method for encoding Unicode characters, whereas BASE64 is a representation method for representing binary data based on 64 printable characters.
[0084] The following example uses Python encoding to convert rare characters from UTF-8 to BASE64 encoding:
[0085] Import base64
[0086] #Assume there is a UTF-8 encoded string
[0087] utf8_str="hello world!"
[0088] # Encode UTF-8 strings to bytes. In Python 3, strings and bytes are two different types.
[0089] utf8_bytes=utf8_str.encode('utf-8')
[0090] #Use base64 module to encode
[0091] Base64_bytes=base64.b64encode(utf8_bytes)
[0092] #Finally, you can decode bytes into strings for printing
[0093] Base64_str=base64_bytes.decode('utf-8')
[0094] Print(base64_str)
[0095] Figure 2 The technical solution provided by the illustrated embodiment, after converting the rare characters from the UTF-8 encoding form to the BASE64 encoding form, further includes:
[0096] S130: Use GBK encoding to encapsulate the rare characters in BASE64 encoding into a communication message and transmit it to the client.
[0097] The BASE64 encoding form can be applied to the GBK encoding of the traditional old application system. In the GBK encoding, the rare characters in the BASE64 encoding form are a string of letters or numbers. In this way, the GBK encoding method can be used to encapsulate the rare characters into a communication message and transmit it to the client. The above method only needs to convert the rare characters in the UTF-8 encoding form in the background application, and does not need to change the intermediate links of the background service. It is not affected by the complexity of the system. Compared with the solution in the background technology that requires each component of the application system to be transformed to support rare characters, the transformation cost is greatly reduced.
[0098] Specifically, as a preferred embodiment, Figure 6 As shown, step S130: using GBK encoding to encapsulate the rare characters in BASE64 encoding into a communication message and transmit it to the client, includes:
[0099] S131: Generate encryption and decryption keys using client authentication information. The client itself has a unique authentication identifier, namely authentication information, which may include client ID, IP address, etc., so that encryption and decryption keys can be generated using the client authentication information and sent to the backend server.
[0100] S132: Encrypt the rare characters in BASE64 encoding format using the encryption and decryption key to obtain an encrypted communication message.
[0101] S133: Negotiate with the client to generate a transmission key. The transmission key is generated through negotiation with the client, so the client can also know the transmission key, and thus decrypt the communication message encrypted by the transmission key.
[0102] S134: Using the transmission key to transmit the encrypted communication message to the client, so that the client uses the encryption and decryption key to decrypt the communication message to obtain the BASE64 code of the rare character.
[0103] Since the communication message is obtained by encrypting the rare characters in BASE64 encoding form using the encryption and decryption key, and the encryption and decryption key is obtained using the client's identity authentication information, when the communication message is sent to the client, the client itself can also use its own identity authentication information to generate the corresponding encryption and decryption key, thereby decrypting the communication message and restoring the rare characters in BASE64 encoding form.
[0104] By using the above method for communication encapsulation, there is no need to modify the components in the intermediate links. Only the input and output ends need to be modified, and the complete rare characters can be restored, thus not being affected by the complexity of the system.
[0105] Figure 2The technical solution provided by the illustrated embodiment, after encapsulating the rare characters in BASE64 encoding form into a communication message using the GBK encoding method and transmitting it to the client, further includes:
[0106] S140: Use the page rendering component of the client to decode the rare characters in BASE64 encoding to obtain the rare characters in UTF-8 encoding.
[0107] The technical solution provided in the embodiment of the present application can restore the rare characters in UTF-8 encoding by decoding the rare characters in BASE64 encoding through the page rendering component. The restoration process is opposite to the above-mentioned conversion process of converting UTF-8 encoding into BASE64 encoding, so that the rare characters in UTF-8 encoding can be obtained.
[0108] In web development, page rendering components (such as React, Vue, Angular, etc.) usually do not directly handle Base64 encoding decoding. However, once a Base64-encoded string exists, JavaScript can be easily used inside the page rendering component to decode rare characters in BASE64 encoding form and use the decoded result for rendering.
[0109] Specifically, as a preferred embodiment, Figure 7 As shown, the above step S140: using the client's page rendering component to decode the rare characters in BASE64 encoding to obtain the rare characters in UTF-8 encoding specifically includes:
[0110] S141: Setting the UTF-8 encoding format of the decoded output in the page rendering component.
[0111] S142: Define a decoding method in the page rendering component, and use the decoding method to encapsulate the UTF-8 encoding format.
[0112] S143: Using a decoding method, decode the rare characters in BASE64 encoding into rare characters in UTF-8 encoding.
[0113] S144: Define a rendering method in the page rendering component, and encapsulate the rendering effect in the rendering method.
[0114] S145: Using a rendering method, rendering the rare characters in UTF-8 format according to the rendering effect, to obtain the rare characters in UTF-8 encoded format after rendering.
[0115] The code to decode rare characters in BASE64 encoding using JavaScript is as follows:
[0116] import React from 'react';
[0117] class Base64DecodeComponent extends React.Component{
[0118] / / Assuming this is a Base64 encoded string obtained from props or state
[0119] base64String = "SGVsbG8sIFdvcmxkIQ = = "; / / "Hello, World!" Base64 encoding
[0120] componentDidMount(){
[0121] / / You can decode here, but usually you decode where you need to display the data
[0122] / / This is just for demonstration
[0123] const decodedString=this.decodeBase64(this.base64String);
[0124] console.log(decodedString); / / Output: Hello, World!
[0125] / / If you need to use the decoded string for rendering, you can store it in state
[0126] / / this.setState({decodedText:decodedString});}
[0127] / / Decode the Base64 encoded string decodeBase64(base64){
[0128] const response = {};
[0129] const charset="charset=UTF-8";
[0130] / / Use atob() function to decode
[0131] / / Note: atob() only works for Base64 encoding of ASCII strings
[0132] / / For UTF-8 strings containing non-ASCII characters (such as Chinese), you need to convert them to Blob first and then read them as text
[0133] try{
[0134] / / For pure ASCII or known safe Base64 strings, you can use atob directly
[0135] return decodeURIComponent(escape(window.atob(base64)));
[0136] / / Or, a safer approach is to use TextDecoder (but not used here for simplicity)
[0137] / / const uint8Array=Uint8Array.from(atob(base64),c=>c.charCodeAt(0));
[0138] / / return new TextDecoder().decode(uint8Array);}catch(err){console.error('Base64 decoding failed:',err);
[0139] return null;
[0140] }
[0141] }
[0142] render(){
[0143] / / Assume that the decoded string has been stored in state
[0144] / / Here we use decodeBase64 directly in the render method to demonstrate const decodedText = this.decodeBase64(this.base64String);
[0145] return(
[0146]
[0147] Decoded text: {decodedText}
[0148] );
[0150] }
[0151] }
[0152] export default Base64DecodeComponent;
[0153] The technical solution provided by the embodiment of the present application is that the page rendering component at the output end decodes the rare characters in the BASE64 encoding form, and through the inverse transformation of the BASE64 algorithm, it can restore the rare characters in the UTF-8 encoding form. There is no need to carry out large-scale transformation of the application system, and the traditional old application system based on GBK encoding can support rare characters. It is not affected by the complexity of the system, which greatly reduces the transformation cost of the system.
[0154] Figure 2 The technical solution provided by the illustrated embodiment, after obtaining the rare characters in UTF-8 encoding, further includes:
[0155] S150: Select a font corresponding to the uncommon character from the system font library to display the uncommon character. The system font library of the client has various fonts built in. The system font library of an old application system that does not support UTF-8 encoding cannot include fonts that support uncommon characters. Therefore, it is necessary to install fonts that support uncommon characters in the system font library of the system in advance to display the uncommon characters.
[0156] Setting the font in the render() method of the page rendering component is usually done through inline styles or CSS classes. This application uses inline styles to select fonts corresponding to uncommon characters. Because using inline styles allows CSS styles to be applied directly to JSX elements.
[0157] Specifically, as a preferred embodiment, Figure 8 As shown, in the above communication encapsulation method, step S150: selecting a font corresponding to an uncommon character from a system character library to display the uncommon character specifically includes:
[0158] S151: Use inline styles to define font display instances in the rendering method;
[0159] S152: using a font display instance to encapsulate a font corresponding to a rare character;
[0160] S153: Using a rendering method, applying the font to the decoding result.
[0161] Figure 8 The relevant codes of the illustrated embodiment are as follows:
[0162] class MyComponent extends React.Component{
[0163] render(){
[0164] const inlineStyle = {
[0165] fontFamily:'Arial,sans-serif', / / Set font
[0166] fontSize:'16px' / / You can set other styles at the same time
[0167] };
[0168] return(
[0169] <div style={inlinestyle}>
[0170] Arial
[0171] );
[0173] }
[0174] }
[0175] The technical solution provided by the embodiment of the present application defines a rendering method in a page rendering component, calls a font that supports the UTF-8 encoded rare characters from a system font library, and outputs and displays them in the selected font, thereby realizing the display of rare characters in traditional old application systems that do not support UTF-8 encoding.
[0176] In summary, in the technical solution provided by the embodiment of the present application, the data source stores uncommon characters in UTF-8 encoding. When receiving an uncommon character request from a client, the uncommon character can be called from the data source. Because the traditional old application system cannot directly support UTF-8 encoding, it is necessary to convert the uncommon character from the UTF-8 encoding to the BASE64 encoding. The uncommon characters in the BASE64 encoding form can be applied to both UTF-8 encoding and GBK encoding. In UTF-8 encoding or GBK encoding, the BASE64 encoding form of the uncommon character is a number and / or letter, so it can be transmitted in an old application system that can only be applied to GBK encoding. In this way, the uncommon characters in the BASE64 encoding form are encapsulated as communication messages and can be transmitted to the client of the old application system. The page rendering component of the client is used to convert the uncommon characters in the BASE64 encoding form into the original UTF-8 encoding form again. In this way, the original uncommon character information can be obtained without causing the loss of the uncommon character information. Finally, the font corresponding to the uncommon character is selected from the system font library to display the uncommon character, so that the uncommon character requested by the customer can be displayed clearly and completely. The above technical solution of the present application does not require any modification of the middle layer that uses non-UTF-8 encoding for communication. It only needs to modify the input and output ends of the old application system that cannot apply UTF-8 encoding to support uncommon characters, which can greatly reduce the complexity of system modification and save system application modification and testing costs.
[0177] To achieve the above purpose, Fig. 9As shown, the present application also provides a communication encapsulation system supporting rare characters, the communication encapsulation system comprising: a backend server 100 and a client 200; the backend server 100 comprises a data source 101 and a backend application 102; the client 200 comprises a page rendering component 201 and a system character library 202; wherein,
[0178] The data source 101 stores rare characters in UTF-8 encoding format;
[0179] The backend application 102 is used to call the corresponding rare characters in UTF-8 encoding form from the data source 101 according to the rare characters request of the client, and convert the rare characters from UTF-8 encoding form to BASE64 encoding form;
[0180] The page rendering component 201 is used to decode the rare characters in BASE64 encoding, obtain the rare characters in UTF-8 encoding, and select a corresponding font from the system font library 202 to display the rare characters.
[0181] Among them, as a preferred embodiment, Fig. 9 As shown, in the above communication encapsulation system, the page rendering component 201 is specifically used for: defining a decoding method, and using the decoding method to encapsulate the UTF-8 encoding form; using the decoding method to decode the rare characters in the BASE64 encoding form into the rare characters in the UTF-8 encoding form; defining a rendering method, and encapsulating the rendering effect in the rendering method; using the rendering method, rendering the rare characters in the UTF-8 form according to the rendering effect, and obtaining the rendered rare characters in the UTF-8 encoding form.
[0182] Among them, as a preferred embodiment, Fig. 9 As shown, in the above communication encapsulation system, the background server 100 also includes a middle-end application 103 and a gateway application 104; the middle-end application 103 is used to generate encryption and decryption keys using the client identity authentication information; the encryption and decryption keys are used to encrypt rare characters in BASE64 encoding to obtain encrypted communication messages; a transmission key is generated through negotiation with the client 200; after the encrypted communication message is transmitted using the transmission key, it is transmitted to the terminal application 203 of the client 200 through the gateway application 104.
[0183] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0184] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
[0185] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes also be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs a specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0186] The modules involved in the embodiments of the present application can be implemented by software or hardware, wherein the name of the module does not limit the unit itself in some cases.
[0187] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A communication packaging method supporting rare fonts, characterized in that: include: According to the client's rare character request, the corresponding rare characters in UTF-8 encoding are called from the data source; Convert the uncommon characters from UTF-8 encoding to BASE64 encoding; Encapsulating the rare characters in the BASE64 encoding form into a communication message and transmitting it to the client; Decoding the rare characters in the BASE64 encoding format using the page rendering component of the client to obtain the rare characters in the UTF-8 encoding format; A font corresponding to the uncommon character is selected from a system character library to display the uncommon character.
2. The communication encapsulation method according to claim 1, characterized in that: The step of converting the uncommon characters from the UTF-8 encoding form to the BASE64 encoding form comprises: Convert the rare characters from UTF-8 encoding to byte form; The base64 module of the python language is used to perform BASE64 encoding on the rare characters in the byte form according to the BASE64 algorithm to obtain the rare characters in the BASE64 encoded form, wherein the base64 module encapsulates the BASE64 algorithm.
3. The communication encapsulation method according to claim 1, characterized in that: The step of using the page rendering component of the client to decode the rare characters in the BASE64 encoding form to obtain the rare characters in the UTF-8 encoding form includes: Setting the UTF-8 encoding format of the decoded output in the page rendering component; Defining a decoding method in the page rendering component, and using the decoding method to encapsulate the UTF-8 encoding form; Decoding the rare characters in the BASE64 encoding form into the rare characters in the UTF-8 encoding form using the decoding method; A rendering method is defined in the page rendering component, and a rendering effect is encapsulated in the rendering method; The rendering method is used to render the rare characters in the UTF-8 format according to the rendering effect, so as to obtain the rare characters in the UTF-8 encoding format after rendering.
4. The communication encapsulation method according to claim 3, characterized in that: The step of selecting a font corresponding to the uncommon character from a system character library and displaying the uncommon character comprises: Use inline styles to define font display instances in the rendering method; Using the font display instance, encapsulate the font corresponding to the uncommon character; Using the rendering method, the font is applied to the decoded result.
5. The communication encapsulation method according to claim 1, characterized in that: The step of encapsulating the rare characters in the BASE64 encoding form into a communication message and transmitting the message to the client comprises: Generate encryption and decryption keys using client authentication information; Encrypt the rare characters in the BASE64 encoding form using the encryption and decryption key to obtain an encrypted communication message; Negotiate with the client to generate a transmission key; The encrypted communication message is transmitted to the client using the transmission key, so that the client uses the encryption and decryption key to decrypt the communication message to obtain the BASE64 code of the rare character.
6. The communication encapsulation method according to claim 1, characterized in that: The step of calling the corresponding uncommon characters in UTF-8 encoding from the data source according to the uncommon characters request of the client comprises: Acquire the query key value of the uncommon character from the uncommon character request of the client; Determine the Value corresponding to the query key value in the form of a key-value pair; The rare characters in UTF-8 encoding format corresponding to the Value value are called from the data source.
7. The communication encapsulation method according to claim 6, characterized in that: Before the step of calling the corresponding uncommon characters in UTF-8 encoding form from the data source according to the uncommon characters request of the client, the method further comprises: storing a rare character table in the data source, and sending all the rare characters in the rare character table at a storage location of the data source to the client; The storage location of the uncommon characters in the data source is used as the Value value and is stored in the client in the form of a key-value pair.
8. A communication encapsulation system supporting rare characters, characterized in that: The system includes: a backend server and a client; the backend server includes a data source and a backend application; the client includes a page rendering component and a system font library; wherein, The data source stores rare characters in UTF-8 encoding; The background application is used to call the corresponding rare characters in UTF-8 encoding form from the data source according to the rare character request of the client, and convert the rare characters from UTF-8 encoding form to BASE64 encoding form; The page rendering component is used to decode the rare characters in the BASE64 encoding form to obtain the rare characters in the UTF-8 encoding form, and select a corresponding font from the system font library to display the rare characters.
9. The communication encapsulation system as claimed in claim 8, characterized in that: The page rendering component is specifically used to: define a decoding method, and use the decoding method to encapsulate the UTF-8 encoding form; Decoding the rare characters in the BASE64 encoding form into the rare characters in the UTF-8 encoding form using the decoding method; Define a rendering method, and encapsulate the rendering effect in the rendering method; The rendering method is used to render the rare characters in the UTF-8 format according to the rendering effect, so as to obtain the rare characters in the UTF-8 encoding format after rendering.
10. The communication encapsulation system according to claim 8, characterized in that: The backend server also includes a middle-end application, which is used to generate an encryption and decryption key using the client identity authentication information; encrypt the rare characters in the BASE64 encoding form using the encryption and decryption key to obtain an encrypted communication message; Negotiate with the client to generate a transmission key; The encrypted communication message is transmitted to the client using the transmission key.