Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-03

RTL functions and file system encoding issues

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Below is a message posted by Valdimir (russian developer). We detected issues in the fpGUI File Open/Save dialog.

Standard RTL functions like FindFirst, FindNext, SetCurrentDir etc all use different encodings based on the OS used. fpGUI uses UTF-8 internally. MSEgui uses WideString internally. Now that Lazarus is moving towards UTF-8 encoding, you guys might start experiencing the same issues.

------------[ Forward ]------------------
Working with SysUtils.FindFirst and FindNext routines I found that the encoding of resulting TSearchRec record fields differs across platforms. Under Windows it seems to be ANSI and under Linux it seems to be UTF-8. The problem is that application expects the same encoding everywhere. Is there any way to determine the resulting encoding to convert fields to the encoding I need?
------------[ end ]------------------

Solution in fpGUI and MSEgui. Create your own RTL functions dependent per platform.
eg:
fpgSetCurrentDirectory()
Under Linux it uses UTF-8 so is a wrapper for RTL SetCurrentDirectory. Under Windows we have to convert UTF-8 to ANSI or WideString and call the appropriate Windows.SetCurrentDirectory[A,W] functions.

This starts making the RTL system functions more difficult to use. Or rather with caution. The developer need to know that instead of the standard RTL functions, they need to use the wrapper functions of the toolkit (fpgFindFirst, fpgFindNext). Anybody else got a better idea in how to solve this issue. Can RTL handle this automatically in any way?

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys
Graeme Geldenhuys wrote 7 lines
Solution in fpGUI and MSEgui. Create your own RTL functions dependent per platform. eg: fpgSetCurrentDirectory() Under Linux it uses UTF-8 so is a wrapper for RTL SetCurrentDirectory. Under Windows we have to convert UTF-8 to ANSI or WideString and call the appropriate Windows.SetCurrentDirectory[A,W] functions.

It was just pointed out to me that not all Linux installations are UTF-8 either (some older systems etc). So more black magic has to happen for Linux's RTL wrapper functions as well.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Florian Klaempfl
to Graeme Geldenhuys
Show quoted text 13 lines
On 12/03/2008, Graeme Geldenhuys wrote: > Solution in fpGUI and MSEgui. Create your own RTL functions dependent > per platform. > eg: > fpgSetCurrentDirectory() > Under Linux it uses UTF-8 so is a wrapper for RTL SetCurrentDirectory. > Under Windows we have to convert UTF-8 to ANSI or WideString and > call the appropriate Windows.SetCurrentDirectory[A,W] functions. It was just pointed out to me that not all Linux installations are UTF-8 either (some older systems etc). So more black magic has to happen for Linux's RTL wrapper functions as well.

Just include cwstrings and assign the file names you get from the rtl functions to widestrings and you're fine. Alternativly you can apply UTF8Encode onto the file name.

Reply by email