Delphi7, FireBird2.5, Windows 10 (English version)

In the database (program), the Russian font is displayed normally.
In MS Word, with Windows 10 (Russian version), the Russian font is displayed normally.
If the English version of Windows is used, then an abracodab is displayed, such as (fig. Below):

enter image description here
At the end of the replay function: AnsiToUtf8, UnicodeToUtf8, UTF8Encode, Utf8ToAnsi, Utf8ToUnicode (when outputting to MSWord) - not suitable
I did this:

... s := UTF8Encode(WideString(ibqEmpty.FieldByName('RusWord').AsString)); WordApplication1.Selection.TypeText(ibqEmpty.FieldByName('EngWord').AsString + ' - ' + Copy(ibqEmpty.FieldByName('RusWord').AsString, 0, 1) + LSpace_empty_FO1C +' - ' + s); 

When you save this document (rtf) in txt (in MSWord, you can choose the encoding), not one came up
And on the form itself, instead of the Cyrillic, stand "?????" (but here it does not depend on the system language)

thank

  • one
    use UTF encoding for the database itself and for displaying information. - gecube
  • I did this: s: = UTF8Encode (WideString (ibqEmpty.FieldByName ('RW1'). AsString)); WordApplication1.Selection.TypeText (ibqEmpty.FieldByName ('EngWord'). AsString + '-' + Copy (ibqEmpty.FieldByName ('RW1'). AsString, 0, 1) + LSpace_empty_FO1C + '-' + s); - ** but this does not work , i.e. CODING CHANGES BUT NOT ON TU - Konstantin78
  • It is not clear exactly where you have a problem. Only with the display on the form, since "everything is normal in the database, normal in MSWord"? - kami

3 answers 3

Usually, this problem occurs when you have a non-Unicode application and the regional settings in Windows are set incorrectly. Set the correct settings through the "Control Panel" and most likely everything works. I repeat - if you do not want to have problems AT ALL, write directly under Unicode. Fortunately, there are no reasons to write in Unicode anymore.

Algorithm description how to correct the situation: https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/int_pr_select_language_version.mspx?mfr=true

  1. Open Regional and Language Options in Control Panel.
  2. Click here for the non-Unicode programs for non-Unicode programs.

Sometimes it does not help. Then recommend to do so:

Start Registry Editor (Start - Run -> regedit).

When performing the following actions, be extremely careful - careless work with the Windows registry can lead to sad consequences!

It is necessary to change the values ​​of the parameters from “1250” to “1255” - set the value for each of these parameters to “c_1251.nls” in the following keys:

Code:

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Nls \ CodePage HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet001 \ Control \ Nls \ CodePage HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet002 \ Control \ Nls \ CodePage

Reboot required.

Encoding fix in Windows XP

To prevent pens from climbing in the Windows registry, try the following:

Create a file in Notepad, copying the text below into it, save with the extension “reg” with any name, English letters, for example 1251.reg, and run it. In 90% of cases with XP, it helps.

Code:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Nls \ CodePage] "1250" = "c_1251.nls" "1251" = "c_1251.nls" "1252" = "c_1251.nls" "1253" = "c_1251.nls" " 1254 "=" c_1251.nls "" 1255 "=" c_1251.nls "

Or correct in the registry branch, responsible for displaying Cyrillic fonts.

Code:

[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Nls \ CodePage]

changing to the following parameters:

Code:

1251 REG_SZ c_1251.nls 1252 REG_SZ c_1251.nls 1253 REG_SZ c_1251.nls

If it does not help, then additionally change:

Code:

1254 REG_SZ c_1251.nls 1255 REG_SZ c_1251.nls

  • 1) Yes, the regional settings may not be very correct, in the sense that I am in Ukraine, and I put out a common language in the system - English (which I need). 2) Replacing registry values ​​with "c_1251.nls" didn’t help either 3) Using tenforums.com/general-support/… , I have "Ukraine" - Konstantin78
  • "It is necessary to change the values ​​of the parameters from" 1250 "to" 1255 "- set the value for each of these parameters to" c_1251.nls "in the following keys:" - never, never, never do that! Because after that, the encoding in correctly written applications very often starts to fail, and finding the cause can be very difficult. - Alekcvp
  • one
    @ Konstantin78, 1) is not the system language, but the default code page for non-unicode applications. Those. how Ansi strings will be interpreted. It does not affect the language of the inscriptions in the system. - Alekcvp
  • What is most disgusting is the fact that everything worked fine in Windows 8.1. - With the "change of c_1251.nls" - it probably went by ... So far, nothing has gone wrong :) - Konstantin78
  • @Alekcvp I want to say two things. The first is the second algorithm (with editing the registry) already for the situation when all means are hopeless. Secondly, this method is for some reason considered to be a classic for treating a localized version of Adobe products (it is repeated from site to site) and does help regularly. Although the chances of hitting the system is always final. - gecube

As far as I remember, in Delphi 7 the type string not Unicode. The encoding is spoiled when you call FieldByName ('RusWord'). AsString. I do not remember whether the AsWideString method is in version 7. If there is, then you need to use it.

  • @ Herman Borisov, if so (var s: WideString; ........ s: = ibqEmpty.FieldByName ('EngWord'). AsString + '-' + Copy (ibqEmpty.FieldByName ('RusWord'). AsString , 0, 1) + LSpace_empty_FO1C + '-' + ibqEmpty.FieldByName ('RusWord'). AsString; WordApplication1.Selection.TypeText (s); The same goes for the crocodile others, and even so they appear in Watches (with step-by-step tracing) - Konstantin78
  • @ Konstantin78, try to replace everything in the last example .AsString with .AsWideString - Herman Borisov

As advised at another forum: " Unicode encoding is not from GetACP, but from 1251 " - this WORKS

 var s: AnsiString; ws: WideString; len: Integer; ........ s := ibqEmpty.FieldByName('EngWord').AsString + ' - ' + Copy(ibqEmpty.FieldByName('RusWord').AsString, 0, 1) + LSpace_empty_FO1C + ' - ' + ibqEmpty.FieldByName('RusWord').AsString; len := Length(s); SetLength(ws, len); len := MultiByteToWideChar(1251, 0, PAnsiChar(s), len, PWideChar(ws), len); if len = 0 then RaiseLastOSError; SetLength(ws, len); WordApplication1.Selection.TypeText(ws); 
  • This means that the data in the database is not in Unicode. The correct solution is to change the data encoding in the database to Unicode. - VladD