Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: New with XE4. Can you recommend a sizing component for this Delphi?


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 7 - Last Post: Oct 18, 2014 10:25 AM Last Post By: Remy Lebeau (Te...
Jorge Uriarte

Posts: 8
Registered: 10/2/09
New with XE4. Can you recommend a sizing component for this Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2014 1:49 PM
Hi there,
I am upgrading to Delphi XE4 and need a sizing component, any recommendations?
Thanks,
Jorge
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: New with XE4. Can you recommend a sizing component for this Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2014 2:30 PM   in response to: Jorge Uriarte in response to: Jorge Uriarte
Jorge wrote:

I am upgrading to Delphi XE4 and need a sizing component,
any recommendations?

What is a "sizing component"? You need to be more specific.

--
Remy Lebeau (TeamB)
Jorge Uriarte

Posts: 8
Registered: 10/2/09
Re: New with XE4. Can you recommend a sizing component for this Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2014 3:18 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
In Delphi 7, I added GTsizer component so that my forms expand to fit any screen. Now with Delphi EX4, is there a recommended component to add?

Also, I am getting Chinese characters in my Memo component when I use memo.lines.LoadFromFile(myfile). myfile is a textfile type. Any advice for this issue?

Thanks
Jorge
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: New with XE4. Can you recommend a sizing component for this Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2014 3:30 PM   in response to: Jorge Uriarte in response to: Jorge Uriarte
Jorge wrote:

Also, I am getting Chinese characters in my Memo component when I
use memo.lines.LoadFromFile(myfile). myfile is a textfile type. Any
advice for this issue?

That can happen if:

1. you did not tell LoadFromFile() what encoding the file is using. It has
an optional TEncoding parameter for that purpose.

2. the file does not have a BOM, so LoadFromFile() could not detect the encoding
automatically.

3. the file is using an encoding than does not match the system default codepage,
which LoadFromFile() falls back to if it does not know what other encoding
to use when reading the file.

--
Remy Lebeau (TeamB)
Jorge Uriarte

Posts: 8
Registered: 10/2/09
Re: New with XE4. Can you recommend a sizing component for this Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2014 7:58 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Jorge wrote:

Also, I am getting Chinese characters in my Memo component when I
use memo.lines.LoadFromFile(myfile). myfile is a textfile type. Any
advice for this issue?

That can happen if:

1. you did not tell LoadFromFile() what encoding the file is using. It has
an optional TEncoding parameter for that purpose.

2. the file does not have a BOM, so LoadFromFile() could not detect the encoding
automatically.

3. the file is using an encoding than does not match the system default codepage,
which LoadFromFile() falls back to if it does not know what other encoding
to use when reading the file.

--
Remy Lebeau (TeamB)

Thanks, but this is a bit complicated. It all worked well with Delphi7. All I am doing is SaveToFile() and LoadFromFile() simple strings. Is there anyway to disable the unicode options so my program will work without modifications?.

Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: New with XE4. Can you recommend a sizing component for this Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2014 8:16 AM   in response to: Jorge Uriarte in response to: Jorge Uriarte
Am 18.10.2014 16:58, schrieb Jorge Uriarte:
Remy Lebeau (TeamB) wrote:
Jorge wrote:

Also, I am getting Chinese characters in my Memo component when I
use memo.lines.LoadFromFile(myfile). myfile is a textfile type. Any
advice for this issue?

That can happen if:

1. you did not tell LoadFromFile() what encoding the file is using. It has
an optional TEncoding parameter for that purpose.

2. the file does not have a BOM, so LoadFromFile() could not detect the encoding
automatically.

3. the file is using an encoding than does not match the system default codepage,
which LoadFromFile() falls back to if it does not know what other encoding
to use when reading the file.

--
Remy Lebeau (TeamB)

Thanks, but this is a bit complicated. It all worked well with Delphi7. All I am doing is SaveToFile() and LoadFromFile() simple strings. Is there anyway to disable the unicode options so my program will work without modifications?.


Hello,

no it is not complicated. You just change all LoadFromFile and
SaveToFile calls and add the following as a 2nd parameter:

TEncoding.ANSI

Doesn't sound complicated, does it?

Greetings

Markus
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: New with XE4. Can you recommend a sizing component for this Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2014 10:25 AM   in response to: Markus Humm in response to: Markus Humm
Markus wrote:

no it is not complicated. You just change all LoadFromFile and
SaveToFile calls and add the following as a 2nd parameter:

TEncoding.ANSI

Doesn't sound complicated, does it?

Or even better, set the TStrings.Encoding property (for SaveToFile()) and
the TStrings.DefaultEncoding property (for LoadFromFile()), then you don't
have to change the LoadFromFile() and SaveToFile() calls themselves.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: New with XE4. Can you recommend a sizing component for this Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2014 10:24 AM   in response to: Jorge Uriarte in response to: Jorge Uriarte
Jorge wrote:

Thanks, but this is a bit complicated.

Not really. When you really dig into it, it is not that hard to deal with.

It all worked well with Delphi7.

Delphi 7 did not care about character encodings. Everything was based on
AnsiString, which at the time held arbitrary 8bit character data and didn't
care how it was encoded. SaveToFile() simply wrote the data to file as-is,
and LoadFromFile() simply read the data as-is, without any interpretation
whatsoever. If the encoding of the file data happened to match the OS default
codepage, everything was OK, otherwise you could get wrong data displayed.

In Delphi 2009 onwards, everything is based on UnicodeString now, so character
encodings are very important when dealing with external data, such as files.
Even AnsiString is encoding-aware now. If the data is not loaded using
the correct encoding, it will not be decoded to Unicode correctly, which
then affects everything that processes the converted data. You have to know
the encoding of the source data you are working with, if it does not describe
its own encoding with a BOM.

All I am doing is SaveToFile() and LoadFromFile() simple strings.

If that is true, then everything should be working fine. SaveToFile() converts
the TStrings data using the OS default codepage unless specified otherwise
(either through its Encoding input parameter, or the TStrings.Encoding property).
LoadFromFile() loads data into TStrings using the OS default codepage unless
told otherwise (either through its Encoding input parameter, the TStrings.DefaultEncoding
property, or a BOM in the file). So you obviously have a mismatch somewhere
between which encoding SaveToFile() uses to create the file and the encoding
LoadFromFile() uses to load the file.

Can you rely on default encodings so you don't have to change existing
code? Yes, if you are careful about it.

Should you rely on default encodings? No, be explicit. There are Encoding
parameters and properties provided for a reason. Use them.

Is there anyway to disable the unicode options so my program will
work without modifications?.

No. We are in a Unicode orld now, you have to account for it.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02