Delphi 7 cyrillic characters not showing correctly - delphi

i recently asked (and paid) for translation of my Delphi app to support Macedonian (Cyrillic font) support.
I posted text to translate to my contracted translator, she sent me back translated strings. The text was extracted from all my .dfm and .pas files
when i replaced the original text with cyrillic translation, i can open .dfm fies also .pas files in my favourite Notepad++ (or notepad) , and i see translated characters correctly.
When i open these files in Delphi (as dpr file) , i see something like this:
Please someone tell me how to convert/display these strings in Delphi correctly.
I am using Macedonian regional settings, but it not helped me with this problem.
PS: Yes I am still using Delphi 7 because i love it / purchased this version.
UPDATE
Original text in Delphi:
original: ПОДГОТВИ КУТИИ ЗРДРУГИТЕ ЦЕÐТРÐЛИ
Correct text:
ПОДГОТВИ КУТИИ ЗА ДРУГИТЕ ЦЕНТРАЛИ
I noticed, when i change ParentFont property to false and font set to Verdana and Cyrillic (RUSSIAN_CHARSET) , then i copy/paste cyrillic text, it shows normally in Delphi

OK so i SOLVED that!
The solution is multi step one, and Notepad++ is needed:
1st step: Replace all fonts in .dfm with (for example) Verdana , or some font that allows Cyrillic support
2nd step: Replace all ParentFont = False to ParentFont = True
3rd step: In notepad++ Choose: Encoding -> Convert to ANSI
that's all, do this for all .dfm and .pas file (only 3rd step)
i am happy to not Listened David Heffernan and not gave up!

Your text file was UTF-8 encoded, whereas Delphi7 requires WinAnsi encoding, with codepage 1251 for Cyrillic characters.
You have the UTF8Decode() function in System.pas to make the conversion programmatically, if you prefer.

Related

TListView truncate hints when using styles

I have a problem with TListView when using Application styles.
Sometimes the hints are truncated. It depends on spaces and length of words in the string.
For example:
'1518 ZL Danovy doklad odeslany' is truncated
'1518ZLDaňový doklad odeslaný' ' is OK
This is happening in Delphi 10.2.1! In Delphi XE7, it was all OK! So I think it must be some kind of bug in this version.
Is there any way of fixing it, or a workaround?
ScreenShot of problem:
Simple project:
https://www.dropbox.com/s/q30i9vlejt1vst7/ListViewTest.7z?dl=0
Things I tried:
removing the LVS_EX_INFOTIP flag (with ViewStyle.vsIcon not working):
ListView_SetExtendedListViewStyle(
ListView1.Handle,
ListView_GetExtendedListViewStyle(LV.Handle) and not LVS_EX_INFOTIP
);
Removing the style from TListView as here:
How to disable VCL styles in Delphi

Android ESC/POS protocol printing in Cyrillic

I bought a no-name Android ESC/POS printer, it support Bluetooth. I need help in printing Cyrillic symbols in Windows-1251 charset. What I do first:
\x1B\x40 (ESC # to initialize printer)
\xD5\xD3\xC9\n (the text that I need to print, standard Windows-1251 symbols, but it shows me some abracadabra :))
I should say, that the charset is set to Windows-1251 on the printer (by the exe tool that comes with it)
Also I tried command \x1B\x74\x49 (it sets the Windows-1251 manually, but there is no effect). Any ideas what we can do with it? Thank you all.
You can try my app that print cyrillic text: https://play.google.com/store/apps/details?id=pe.diegoveloper.printerserverapp
Configure your ESC/POS printers on 'Quick Printer' and print from your app.
I tried many variants and after this manual end up with this character code page settings { 27, 116, 9 }
outputStream.write(new byte [] { 27, 116, 9 });
outputStream.write("Привет Мир".getBytes("cp866"));
outputStream.write(PrinterCommands.LF);
Try to convert your text to cp866.
And set code page in printer via ESC/POS command into 17.
With Universal Cyriclic decoder you can find your source encoding/decoding.
Enter in decoded field your output text. For example 袩褉懈胁械褌.
Select source encoding UTF-8.
Then find your wanted decoding charset by selecting field "display as".

Multilanguage with Firemonkey (Delphi)

I'm looking for a solution to change the language at runtime. (Firemonkey / Delphi)
TLang works, but I get weird strings in an empty project. (e.g. Samsung Galaxy Nexus and other mobile stuff) And I prefer another solution and not string-replace like TLang.
Unfortunately, resourcestring doesn't work. I tried to translate the resourcestrings with "resource dll expert" (IDE RAD Studio XE5). And the example application "RichEdit" also doesn't work.
Any idea?
Okay I found the problem, why it isn't running. The tool have some bugs. The path to the Project.exe can not contain spaces.
Another solution is Stringtable like this:
// default.rc file
#define firstString 1
#define secondString 2
STRINGTABLE
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
BEGIN
firstString , "Neutral String 1"
secondString , "Neutral String 2"
END
// english.rc file
#define firstString 1
#define secondString 2
STRINGTABLE
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
BEGIN
firstString , "First String"
secondString , "Second String"
END
And than {$R default.res default.rc} {$R english.res english.rc} into the *.pas file. To use the transalation: LoadStr(2)
With an resource-editor, I can see the two languages. But how I can change the default/neutral to another language at runtime. Is there a kind of "SetLanguage" function in Delphi?
For simple projects TLang works fine, but the included "Language Designer" (doubleclick on the TLang component) is not much fun.If you want to translate and handle your strings extern you only can import external languages files one by one and have to import all again, if some texts change.
I wrote a small tool to handle texts extern in a spreadsheet and convert this texts to the LNG format:
See TLang converter
For large projects you may also check out some commercial products for translating/localization of Delphi FMX projects like:
http://www.sisulizer.de
http://www.tsilang.com
http://www.regulace.org

LoadFromFile with Unicode data

My input file(f) has some Unicode (Swedish) that isn't being read correctly.
Neither of these approaches works, although they give different results:
LoadFromFile(f);
or
LoadFromFile(f,TEncoding.GetEncoding(GetOEMCP));
I'm using Delphi XE
How can I LoadFromFile some Unicode data....also how do I subsequently SaveToFile? Thanks
In order to load a Unicode text file you need to know its encoding. If the file has a Byte Order Mark (BOM), then you can simply call LoadFromFile(FileName) and the RTL will use the BOM to determine the encoding.
If the file does not have a BOM then you need to explicitly specify the encoding, e.g.
LoadFromFile(FileName, TEncoding.UTF8);
LoadFromFile(FileName, TEncoding.Unicode);//UTF-16 LE
LoadFromFile(FileName, TEncoding.BigEndianUnicode);//UTF-16 BE
For some reason, unknown to me, there is no built in support for UTF-32, but if you had such a file then it would be easy enough to add a TEncoding instance to handle that.
I assume that you mean 'UTF-8' when you say 'Unicode'.
If you know that the file is UTF-8, then do
LoadFromFile(f, TEncoding.UTF8).
To save:
SaveToFile(f, TEncoding.UTF8);
(The GetOEMCP WinAPI function is for old 255-character character sets.)

BlackBerry - language support for Chinese

I have localised my app by adding the correct resource files for various European languages / dialects.
I have the required folder in my project: ./res/com/demo/localization
It contains the required files e.g. Demo.rrh, Demo.rrc, Demo_de.rrc etc.
I want to add support for 2 Chinese dialects, and I have the translations in an Excel file. On iPhone, they are referred to by the codes zh_TW & zh_CM. Following the pattern with German, I created 2 extra files called Demo_zh_TW.rrc & Demo_zh_CN.rrc.
I opened file Demo_zh_CN.rrc using Eclipse's text editor, and pasted in line of the Chinese translation using the normal resource file format:
START_LOCATION#0="开始位置";
When I tried to save the file, I got Eclipse's error about the Cp1252 character encoding:
Save could not be completed.
Reason:
Some characters cannot be mapped using "Cp1252" character encoding.
Either change the encoding or remove the characters which are not
supported by the "Cp1252" character encoding.
It seems the Eclipse editor will accept the Chinese characters, but the resource tool expects that these characters must be saved in the resource file as Java Unicode /u encoding.
How do I add language support for these 2 regions without manually copy n pasting in each string?
Is there maybe a tool that I can use to Java Unicode /u encode the strings from Excel so they can be saved in Code page 1252 Latin chars only?
I'm not aware of any readily available tools for working with BlackBerry's peculiar localization style.
Here's a snippet of Java-SE code I use to convert the UTF-8 strings I get for use with BlackBerry:
private static String unicodeEscape(String value, CharsetEncoder encoder) {
StringBuilder sb = new StringBuilder();
for(char c : value.toCharArray()) {
if(encoder.canEncode(c)) {
sb.append(c);
} else {
sb.append("\\u");
sb.append(hex4(c));
}
}
return sb.toString();
}
private static String hex4(char c) {
String ret = Integer.toHexString(c);
while(ret.length() < 4) {
ret = "0" + ret;
}
return ret;
}
Call unicodeEscape with the 8859-1 encoder with Charset.forName("ISO-8859-1").newEncoder()
I suggest you look at Blackberry Hindi and Gujarati text display
You need to use the resource editor to make these files with the right encoding. Eclipse will escape the characters automatically.
This is a problem with the encoding of your resource file. 1252 Code Page contains Latin characters only.
I have never worked with Eclipse, but there should be somewhere you specify the encoding of the file, you should set your default encoding for files to UTF-8 if possible. This will handle your chinese characters.
You could also use a good editor like Notepad++ or EMEditor to set the encoding of your file.
See here for how you can configure Eclipse to use UTF-8 by default.

Resources