开发者

display German special characters correctly in Delphi 2007

I need to display German special 开发者_如何学编程characters correctly in Delphi 2007 as for now I get characters like this "ü" appear like "?" in label components

any advise

Thanks


Unexpected question mark (?) shows up when text goes trough a code page conversion that fails.

Since Delphi 2007 is not Unicode Enabled, your label's Caption is an AnsiString. The text you're putting in there goes trough at least one code page conversion that fails, and you'll have to figure out where the conversion takes place and why it's failing.

Common causes for code page conversions:

  • The text for your Label comes from the DFM (you wrote it in Object Inspector). Your machine and the test machine both use different "default code pages for non-Unicode applications". You should never see this while testing on your machine.
  • The text for your Label came from a database, and either the database has the wrong code page or your test machine has the wrong code page: when Delphi helpfully tries to convert the code page, it fails.
  • The Character Set property of your Label's font is wrong.

Here's a bit of code to put the ü character in a Label for testing. The code selects the EASTEUROPE_CHARSET so I know I'm dealing with code page 1250. I'm doing so because the other Charset constants either select unusable code pages (that don't include the "ü") or select a code page that depends on the OS (ie: no actual change).

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Font.Charset := EASTEUROPE_CHARSET;
  Label1.Caption := Char(252);
end;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜