Delphi and Russian/Greek characters? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Delphi and Russian/Greek characters?

ljubaljuba Posts: 106Member
Hello,

I am creating program using Delphi 5 which reads text in one Memo field character by character and if find some special character in second memo I put html code for that character, so that text from second field will be used on Web. With English text if I want to replace 'd' or 'e' or whatever with some #3432 or similar - it works fine.

But with Russian/Greek/Swedish/... characters I have 2 problems.

1. In code if I want to define what character to replace with what code:

case Memo1.Text[counterX] of
'А': Memo2.Text := Memo2.Text + 'А';
'Б': Memo2.Text := Memo2.Text + 'Б';
'В': Memo2.Text := Memo2.Text + 'В';
...
else
Memo2.Text := Memo2.Text + Memo1.Text[counterX];
end;

In Delphi IDE i get like this:

case Memo1.Text[counterX] of
'?': Memo2.Text := Memo2.Text + 'А';
'?': Memo2.Text := Memo2.Text + 'Б';
'?': Memo2.Text := Memo2.Text + 'В';
...
else
Memo2.Text := Memo2.Text + Memo1.Text[counterX];
end;

So how I can write russian or any other non-latin character in source code in IDE?

2. When I run program, and if I select in Windows Russian keyboard - when I write in memo field - I am getting ? instead character. And in MS Word I am getting normal russian characters.

PS: Same problem I have with Greek/Swedish/Thai/... languages.

Can somebody suggest something how I can fix these problems? Thanks

Regards,

Aleksandar

Comments

  • zibadianzibadian Posts: 6,349Member
    : Hello,
    :
    : I am creating program using Delphi 5 which reads text in one Memo field character by character and if find some special character in second memo I put html code for that character, so that text from second field will be used on Web. With English text if I want to replace 'd' or 'e' or whatever with some #3432 or similar - it works fine.
    :
    : But with Russian/Greek/Swedish/... characters I have 2 problems.
    :
    : 1. In code if I want to define what character to replace with what code:
    :
    : case Memo1.Text[counterX] of
    : 'А': Memo2.Text := Memo2.Text + 'А';
    : 'Б': Memo2.Text := Memo2.Text + 'Б';
    : 'В': Memo2.Text := Memo2.Text + 'В';
    : ...
    : else
    : Memo2.Text := Memo2.Text + Memo1.Text[counterX];
    : end;
    :
    : In Delphi IDE i get like this:
    :
    : case Memo1.Text[counterX] of
    : '?': Memo2.Text := Memo2.Text + 'А';
    : '?': Memo2.Text := Memo2.Text + 'Б';
    : '?': Memo2.Text := Memo2.Text + 'В';
    : ...
    : else
    : Memo2.Text := Memo2.Text + Memo1.Text[counterX];
    : end;
    :
    : So how I can write russian or any other non-latin character in source code in IDE?
    :
    : 2. When I run program, and if I select in Windows Russian keyboard - when I write in memo field - I am getting ? instead character. And in MS Word I am getting normal russian characters.
    :
    : PS: Same problem I have with Greek/Swedish/Thai/... languages.
    :
    : Can somebody suggest something how I can fix these problems? Thanks
    :
    : Regards,
    :
    : Aleksandar
    :
    Try changing the Font of the memo, especially the Charset property of the font. The default set is set to western characters only.
  • ljubaljuba Posts: 106Member
    [b][red]This message was edited by ljuba at 2006-10-18 8:9:59[/red][/b][hr]
    [b][red]This message was edited by ljuba at 2006-10-18 8:8:52[/red][/b][hr]
    : Try changing the Font of the memo, especially the Charset property of the font. The default set is set to western characters only.
    :
    Thanks.

    I tried ... and if I change just for memo field - doesn't work. If I change that for whole form - it works ... so like that I can solve 2nd problem. But still exist problem how to write russian/... characters in source code ... te predefine in case condition what to do in what situation.

    How to write differently following case:

    case Memo1.Text[counterX] of
    'А': Memo2.Text := Memo2.Text + 'А';
    'Б': Memo2.Text := Memo2.Text + 'Б';
    'В': Memo2.Text := Memo2.Text + 'В';
    ...
    else
    Memo2.Text := Memo2.Text + Memo1.Text[counterX];
    end;

    Even here I couldn't write A, B, V, ... in russian but you understood problem.
  • ljubaljuba Posts: 106Member
    How I can go character by character in Memo.text and compare by ascii value? Chr? ...

    case Memo1.Text[counterX] of
    '#1040;': Memo2.Text := Memo2.Text + 'А';
    'Б': Memo2.Text := Memo2.Text + 'Б';
    'В': Memo2.Text := Memo2.Text + 'В';
    ...
    else
    Memo2.Text := Memo2.Text + Memo1.Text[counterX];
    end;

    Thanks
  • zibadianzibadian Posts: 6,349Member
    : How I can go character by character in Memo.text and compare by ascii value? Chr? ...
    :
    : case Memo1.Text[counterX] of
    : '#1040;': Memo2.Text := Memo2.Text + 'А';
    : 'Б': Memo2.Text := Memo2.Text + 'Б';
    : 'В': Memo2.Text := Memo2.Text + 'В';
    : ...
    : else
    : Memo2.Text := Memo2.Text + Memo1.Text[counterX];
    : end;
    :
    : Thanks
    :
    In the source code, you can use the unicode codes: #65 for example is captical A. Thus #1040 is the first character of your case statement.
    Note: The greek/chinese/russian/.. characters are not part of the ASCII set, but the unicode set. ASCII has only 127 characters. For more info: http://en.wikipedia.org/wiki/Unicode and http://en.wikipedia.org/wiki/Ascii.
Sign In or Register to comment.