Multi-language programming resource conversion

zhaozj2021-02-08  259

Department of Internal Instrument, Hunan Provincial Public Security College (410006) Yang Xia

1. Resource conversion problem of multi-language programming

People in different countries use different languages. In Microsoft Window

S, the language code page is identified, and the different languages ​​are expressed in different code pages, such as "Simplified Chinese).

Text "use code page 936," US English "is represented by code page 1252.

When developing applications with Visual C , it is generally stored in the language.

In the source file (* .rc file), therefore, to prepare different language applications (such as Chinese applications)

Order, English app), substantially requires resource documents of different languages. In real

In the programming, we can compile different language resources into a corresponding dynamic connection library.

In this way, when used, the code page can be used according to the code page used by the operating system, and the corresponding language is selected.

Dynamic connection libraries compiled by resource files can be run normally. This

It is a so-called multi-language programming issue.

When developing Chinese applications, often require applications in Chinese operating systems and in English.

Operating system plug-in Chinese character platform can run normally. But due to work ring

Different, often lead to the same application, working properly in some environment, in another

It is not working properly in the environment. If the Chinese version of Microsoft Word software, in Chinese

Make normal operation under the system, but in English operating system plug-in Chinese character platform,

The display is a pile of garbled.

To solve this problem, you need to prepare different language resource files for different language operating systems.

In fact, this is also a multi-language programming issue. Different from the information displayed at this time

It does not need to change with the language (no matter which environment only shows Chinese information),

Multiple language resource files can have a very simple method, which is the resource turn of this article to be discussed.

Change the problem. This problem can be simply described as: if there is a resource file of a certain language,

How to convert it to another language resource file with the constant resource content. E.g,

There is a resource file of Simplified Chinese (code page 936), in the case of resource content.

How to convert it to a resource file for US English (code page 1252).

2. How to make resource conversion

Below to convert the resource file from the code page 936 (Simplified Chinese) to the code page 1252 (US)

National English) Take an example.

It is easy to think that the method of disaster consequence is to directly modify the resource attribute. This

The method process is to switch the VIS UAL C Workspace window to Resource View.

Select a resource, click Right click, from the pop-up menu, select the "Properties" command, at this time

A dialog box will pop up. In the pop-up dialog, modify the value of the language item,

Change it from "Simplified Chinese" to "American English". This is the other of the resource view

The resources are modified, and the Language properties of all resources are changed to "American English".

However, after this modification, open the resource, it will find that the content in the resource becomes a bunch.

Readable garbled. More deadly, even if the property of the Language item of the resource is reset to "

"Simplified Chinese", resource content is still unreadable. That is, we have no

Law resumes the original content. Therefore, if there is no resource backup before modification, this modification

The consequences will be disastrous.

The correct way is to open the resource file with a text editor (such as edit, notepad)

, Find the word "la nguage", you can see the following:

//

// Chinese (P. R. C.) Resources

#if! defined (AFX_RESOURCE_DLL) || Defined (AFX_TARG_CHS)

#ifdef _win32

Language lang_chinese, SUBLANG_CHINESE_SIMPLIFIED

#pragma code_page (936)

#ENDIF / / / WIN32

This code represents the currently used code page as 936, the language represented is Simplified Chinese

. Replace the above code segment to replace the following code segment

//

// English (u.s.) Resources

#if! defined (AFX_RESOURCE_DLL) || Defined (AFX_TARG_ENU)

#ifdef _win32language lang_english, SUBLANG_ENGLISH_US

#pragma code_page (1252)

#ENDIF / / / WIN32

The above code description The resource uses the code page as 1252, which represents the language of America.

After simple modification, you can convert the code page as 936 resource file to the code page.

1252 resource files, and resource content constant.

转载请注明原文地址:https://www.9cbs.com/read-1417.html

New Post(0)